rubyonrailsin

A Ruby and Rails talk

Monday, March 29, 2010


[Rails] Updating records

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

So I would like to be able to update a record without having to load the
edit page. Lets use checking out a book as an example. From the front
page of my application I would like to be able to have a form field
where I can enter a record id and select one of a couple of check boxes
and then hit submit which will update the associated record with the
action selected by the check box (check out, check in, etc). I am
assuming I need to use a form_tag but I am not sure how to go about
writing the controller and I am assuming I will need to do some custom
routing.

def update

@barcode = params[:barcode]
@checkout = params[:checkout]

@book = Book.find(:first, :conditions => {:barcode => [@barcode]})

@book.update_attributes(params[:book])

end
--
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 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.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive