Tuesday, 27 August 2013

Ruby on Rails - button_to using routes to call function from controller

Ruby on Rails - button_to using routes to call function from controller

Hello right now I've a problem about button_to
I want to setup a button that call a method in controller, this is how I
setup the button :
(this located in issues/_edit.html.erb)
<%= button_to "Cancel Return", :action => "cancel_return", :controller =>
"issues" %>
and I want this will call this function in issues_controller.rb
def cancel_return
@issue.cancel_return(params)
end
but it can't work, I already tried to declare cancel_return as
helper_method, but it also didn't work. is there any other solution? or
I'm doing it wrong? I'm using ruby version 1.9.3p125 and rails version
2.3.15, I used old version because I tried to modify redmine, any help
will be appreciated.
Thanks

No comments:

Post a Comment