I have a method defined in my controller that I am trying to create a button or form to access.
Model
class DoThis < ActiveRecord::Base
def take_action(a, b)
end
end
View
<%= @do_this.take_action(@a, @b) %>
I would like to convert the above code in the View to a button_to or form_for but cannot figure out how.
Thanks
You shouldn’t do this. Models should never contain view code – it’s intentionally not easy to do that, because it breaks MVC. Instead, you should add a helper function in your
app/helpers/controller_name_helper.rbfile.Then, you’ll just call
<%=take_action(@do_this) %>in your view.