2011-10-31 58 views

回答

1

您不能发布到helper方法execpt如果helper方法也是控制器动作

class SampleController << ApplicationController 
    helper_method :helper_and_action 

    def helper_and_action 
    # do some stuff 

    # you need to skip render view if you use this method as helper 
    end 

end 

注册它route.rb

post "sample/helper_and_action", :controller=> :sample, :action=> :helper_and_action 

然后使视图类似下面

<%= form_tag {:controller => :sample, :action=> :helper_and_action } do |f| %> 
... its up to you what will go here 
<% end %>