Thursday, January 19, 2012

[Rails] Merging URL parameters with form_for ones

Hello!

I am using the standard (scaffolded), REST routing. I need to pass
external values to my "new" action for a certain model, and let the
user complete the other fields in the standard form_for.
My initial idea has been to simply amend the URL like this:

.../foos/new?size=4&weight=2

Then in the controller I just do something like:

def new
@temp = Foo.new
@temp.size = params[:size]
...

respond_to do |format|
format.html
format.xml { render :xml => @temp }
end

end

Thing is my form_for parameters are not picked up. Only the ones I
have setup manually in the URL (size and weight in my example) are
taken into account.
I believe it is due to the fact that they are serialized and added to
the end of the URL, whereas it already contains a "?" and some
parameters so they end up being ignored.

Do you know how to do this?

Thanks!
PJ

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate