RAILS3: Pass arbitrary parameters via button_to?

后端 未结 5 1966
北海茫月
北海茫月 2020-12-30 04:02

I\'m trying to do something very simple in my first Rails app (Rails 3) and I\'m not sure what I\'m doing wrong, or if there\'s a better approach. Can\'t find anything on th

5条回答
  •  滥情空心
    2020-12-30 04:36

    In article#show

    <%= button_to("Add WorkRequest", {:controller => "work_request", :action => "new", :article_id => @article.id})%>

    In work_requests#new

    <%= f.text_field :article_id, :value => params[:article_id]%>

提交回复
热议问题