RE: A simple scaffolding question

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.

On 1/19/06, Hogan, Brian P. [email protected] 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