0
我想知道如何创建一个提交给助手方法的表单?rails 3.1,我如何定义一个发布到帮助器方法的表单?
我不需要为控制器中的某些动作编写路由,因为此表单将使用收音机收集信息&复选框,然后,我将在助手中创建一个模型并进行重定向。
我想知道如何创建一个提交给助手方法的表单?rails 3.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 %>