HOGANBP
1
Huh?
Oh you’re probably referring to scaffolding.
Well, you could just do it by hand.
Say your table looks like this:
Authors
id
first_name
last_name
email
Controller:
def list
@authors = Author.find(:all)
# or you might have paginate stuff there instead
end
View:
Just write this code by hand:
First Name |
Last Name |
<% for author in @authors %>
<%=author.first_name %> |
<%=author.last_name %> |
<% end %>
Don’t fear the HTML 
HOGANBP
2
i tried your solution, but it didn´t seem “clean” to me.
i thought of something like (referring to the example):
@authors = Author.find(‘first_name’,‘last_name’)
of course, this code is not correct. but there should be an easier way
than
modifying the HTML by hand, right?
patrick
HOGANBP
3
patrick k wrote:
i tried your solution, but it didn´t seem “clean” to me.
i thought of something like (referring to the example):
@authors = Author.find(‘first_name’,‘last_name’)
of course, this code is not correct. but there should be an easier way than
modifying the HTML by hand, right?
No, generated HTML is just to get you started. You should expect to
replace it completely.
Justin
HOGANBP
4
define a subset of Author.content_columns in your controller and then
use this in your scaffold loop instead of Author.content_columns
directly:
desired_columns = [‘first_name’, ‘last_name’]
@content_columns = Author.content_columns.select { |c|
desired_columns.include?(c.name) }
HOGANBP
5
nice. tried it and … worked. thanks.
looks like this is a more appropriate way to handle the problem compared
with changing the HTML-code.
this should be part of the tuturial, wiki … (maybe it already is, but
i
didn´t find it).
HOGANBP
6
Hi:
I am a newbie too so this answer may be junk. However, here goes…
(all the techno geniuses please be nice, I am attempting to be helpful).
@authors = Author.find(:select => 'first_name, last_name,etc) etc.
However, the other answer you were given is perfectly “clean” in my
opinion and certainly gives more control.
bruce