Skip to content

Commit

Permalink
Avoid including ApplicationHelper in a controller
Browse files Browse the repository at this point in the history
Because this would define all helper methods as action_methods. Instead,
let's call helper methods in view files as usual.
  • Loading branch information
amatsuda committed Mar 9, 2025
1 parent 046225a commit 36922e7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions app/controllers/proposals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,12 @@ def update
end
end

include ApplicationHelper
def parse_edit_field
respond_to do |format|
format.js do
render locals: {
field_name: params[:name],
text: markdown(params[:text])
text: params[:text]
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/proposals/parse_edit_field.js.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$('[data-field-name="<%= field_name %>"]')[0].innerHTML = '<%=j text %>';
$('[data-field-name="<%= field_name %>"]')[0].innerHTML = '<%=j markdown(text) %>';

0 comments on commit 36922e7

Please sign in to comment.