On Jun 7, 1:55 pm, Jacob A. [email protected] wrote:
contact = Contact.new( :name => params[:name], :address =>
everything related to a contact is put into the params[:contact] hash.
If you use the built in helpers for creating your input tags, you get
the “scoping” for free.
Thanks for both responses.
I’m creating a contact via an Ajax call, not using a form. The url is
“/contact/add?name=joe&address=Broadway” - so in this case, I should
scope it with “/contact/add?
contact[name]=joe&contact[address]=Broadway” - is that right?
That seems to be a little excessive, but I suppose cleaner.
This might be a good time to look into routing
should be able to create a creative route to handle the details (I
haven’t tested this, so no promises):
:controller => contact, :action => add
At least this way you keep the url ugliness from your customer.
Otherwise, you can always setup something like:
map.connect ‘/contact/add?*details’, :controller => contact, :action =>
and then your contact details will be passed in their own variable. The
problem I’ve found with params is that it ends up containing a lot of
details about the rails transaction that you, most likely, don’t need.
Also, there’s nothing wrong with parsing out the params and then
creating the row. Don’t worry, Ruby won’t bite!