[Rails] A "Rails" way to design a list-like page with CRUD
capabilities?
Brian L.
zorander at gmail.com
Wed Jan 19 01:54:58 GMT 2005
I've often wondered the same thing. Given the way that rails parses
CGI, you could make fields named people[2][firstname] and then update
Person.find(2) with the data in @params['people'][2] (assuming you use
attr_protected in the appropriate places in your model, of course).
This assumes that 2 is the id. Then at the bottom you put your update
button. I'm kinda pulling this out of nowhere but I think it will
work.
For simple 'click to remove' buttons, I tend to use a link with a get
request to immediately remove the item.
Brian
On Tue, 18 Jan 2005 17:57:43 -0700, Duane Johnson
<duane.johnson at gmail.com> wrote:
> So I've finally figured out how to make simple and elegant
> Create/Read/Update/Delete events for a single object such as @person.
> But how do the Rails experts do it for a list of objects?
>
> For example:
>
> class TestController < ApplicationController
> def list
> @people = Person.find_all
> end
> end
>
> The corresponding list.rhtml view will elegantly display the array of
> Person objects. But what if each "Person" row in the view is
> editable? For example, the view I am imagining would generate a text
> box for the first name, last name and phone number, all the way down
> the list, and a check box next to each person to delete the
> corresponding person from the database. Is there an elegant solution
> to this pattern in Rails? Any sample code from those of you who've
> come across this and solved it before?
>
> Thank-you,
> Duane Johnson
> (canadaduane)
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
The years ahead pick up their dark bags.
They move closer. There's a slight rise in the silence
then nothing.
--
(If you're receiving this in response to mail sent to
bluczkie at andrew.cmu.edu, don't be concerned This is my new address,
but mail will be forwarded here indefinitely)
More information about the Rails
mailing list