Noob question about the "show" function


#1

i’ve got a cool app going and it’s getting bigger and bigger, but now
i’m trying to customize the show function. i’m using the scaffold code
as a base but can’t seem to get anything to look right. i guess i’m
confused about how exactly the scaffold code works for the “show”
function. any help would be awesome! thanks.

jon


#2

Jon Mr wrote:

i’ve got a cool app going and it’s getting bigger and bigger, but now
i’m trying to customize the show function. i’m using the scaffold code
as a base but can’t seem to get anything to look right. i guess i’m
confused about how exactly the scaffold code works for the “show”
function. any help would be awesome! thanks.

What exactly are you trying to achieve?


#3

Alex Y. wrote:

What exactly are you trying to achieve?

it show’s too much information…
like this…

Monday: 1

Tuesday: 1

Wednesday: 1

Thursday: 1

Friday: 0

Saturday: 1

Sunday: 0

i only want to display the ones that were checked. but i can’t get it to
not display all of it. any suggestions?


#4

Jon Mr wrote:

Tuesday: 1

i only want to display the ones that were checked. but i can’t get it to
not display all of it. any suggestions?

I presume from this that each weekday is represented as a column in your
object table. In that case, rather than the current show code which
looks like this:

<% for column in ModelName.content_columns %>

<%= column.human_name %>: <%=h @model_name.send(column.name %>

<% end %>

you probably want to do something like:

<% for column in ModelName.content_columns
if @model_name.send(column.name) == 1 %>

<%= column.human_name %>

<% end end %>

#5

Why don’t you set a :condition in your find() method to only return the
ones
where checked = 1?

something like find(:all, :condition => “checked = 1”)

I don’t know if the syntax is exactly correct, but would that work?

Ryan