Flowdock

Notes posted by kapitan-petko

RSS feed
June 25, 2012 - (<= v2.3.8)
0 thanks

Adding Additional Parameters to form_for

If you want to add additional parameters to the form_for helper, but still want to use one form for both your “create” and your “update” actions, you can add the additional parameters to the :url option, but you need to omit the :controller and :action keys.

form_for(@user, :url => {:param1 => "value1", :param2 => "value2"}) do |f|

or

form_for([@post, @comment], :url => {:param1 => "value1", :param2 => "value2"}) do |f| 

where param1 and param2 are not :controller or :action

June 20, 2012 - (>= v3.0.0)
1 thank

add_to_base in Rails 3

In addition to stevo’s note, in Rails 3 you can also do:

model_instance.errors.add(:base, "Msg")