Forum: Ruby on Rails RE: A simple scaffolding question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
60e38de043848f82392062088f191213?d=identicon&s=25 Hogan, Brian P. (Guest)
on 2006-01-19 20:10
(Received via mailing list)
Account_ID will not show up in scaffolding.

That's not important though.. Scaffolding is not meant for production,
it's meant for you to have a place to start. In fact, as you get better,
you'll rely on it less and less.

The record ID is already there.

In your "show" action you should have this:

@service = Service.find(params['id']


And on your page, simply doing @service.id gives you the record id.  You
usually never show that on a page because it's considered to be a
surrogate key... One that means nothing to a user. Based on that
assumption, scaffolding will ignore that as well.
0a1f61c4a643e6216024d7e522fb7ccd?d=identicon&s=25 Nick Pavlica (Guest)
on 2006-01-19 20:55
(Received via mailing list)
On 1/19/06, Hogan, Brian P. <HOGANBP@uwec.edu> wrote:
> Account_ID will not show up in scaffolding.

Is it because of it's data type?  I would think that by default
everything would be available with the exception of the default id
primary key.

> That's not important though.. Scaffolding is not meant for production,
> it's meant for you to have a place to start. In fact, as you get better,
> you'll rely on it less and less.

That makes sense, it is a little curious that it drops the account_id
field in this case.  Possibly because it has 'id' in its name and is
filtered automatically as it would the 'id' PK.

>
> The record ID is already there.
>
> In your "show" action you should have this:
>
> @service = Service.find(params['id']

This was allready in my the show action in my controller.  I added
       Record ID: <%= @service.id %>
to my show view and everything  works just fine.

Now I'm trying to add the id field to the list view.  In my controller
the action is:

def list
    @service_pages, @services = paginate :services, :per_page => 10
end

When I add <%= @service.id %> to the view it dies.  Shouldn't all of
the attributes be available?


> And on your page, simply doing @service.id gives you the record id.  You
> usually never show that on a page because it's considered to be a
> surrogate key... One that means nothing to a user. Based on that
> assumption, scaffolding will ignore that as well.

I was using it as my record id wich is very important in my case.
Because of the Rails conventions, I wounder it it would be better to
just at another serial field that isn't the "id" field.  It just seams
like a waste of space though..

--Nick
This topic is locked and can not be replied to.