How to pass parameter via MVC using link_to method?
View:
<%= link_to "Remove Tag", remove_tag_issue_path(issue)%>
How to use link_to method to use remove_tag action?
issues_controller.rb def remove_tag(parameter) @issue.remove_it(parameter) end
issue.rb
def remove_it(parameter) self.users.delete(User.find(parameter)) end
In the controller
def remove_tag @issue.remove_it(params[:my_param]) end
And in sight
<%= link_to "Remove Tag", remove_tag_issue_path(issue, :my_param => "Hello world")%>
In the view, use the following
<%= link_to 'Remove Tag', remove_tag_issue_path(:issue => @issue)%>
and in the controller
def remove_tag @issue.remove_it(:issue => params[:issue]) end
Source: https://habr.com/ru/post/1345367/More articles:WPF Get image from RESX file - imageruby support in vim on windows - windowsRuby: setting a global variable by name - ruby ββ| fooobar.comPreview via JSONArray in PHP - jsonWhat is the "No iPhone OS device connected" error message. I mean? - iphoneworking with function prototypes and arrays in C - cJVM stack variables - javaUsing Web Deploy Tool for IIS - Works with an administrator account, but not with an IIS or Windows user account - visual-studioReturn iterating object and index on repeat - ruby ββ| fooobar.comErlang releases best practices? - erlangAll Articles