7stud -- wrote:
> 
> Link.create("url" => params[:url])
> 
> (that assumes the links table has only one field: url)
> 
> Apparently when you assign a Link object to the variable @link, rails 
> will create a record in the database corresponding to the values in the 
> Link object.  If you look at the create method in the file 
> LinksController.rb, that is what the create method does.  This is what I 
> came up with:
> 
> @link = Link.create("url" => params[:url])
> 

After some more testing, I discovered that you don't have to assign the 
Link object to @link.  I think that when you create a Model object(e.g. 
a Link object) and the Model is hooked up to a database, then as soon as 
you create the object, rails inserts a record corresponding to that 
object in the table.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to