Forum: Ruby on Rails Noob question about the "show" function

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.
Jon M. (Guest)
on 2006-03-17 21:58
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
Alex Y. (Guest)
on 2006-03-17 22:44
(Received via mailing list)
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?
Jon M. (Guest)
on 2006-03-18 00:25
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?
Ryan P. (Guest)
on 2006-03-18 00:34
(Received via mailing list)
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
Alex Y. (Guest)
on 2006-03-18 19:05
(Received via mailing list)
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 %>
<p>
   <b><%= column.human_name %>:</b> <%=h @model_name.send(column.name %>
</p>
<% end %>

you probably want to do something like:

<% for column in ModelName.content_columns
if @model_name.send(column.name) == 1 %>
<p>
   <b><%= column.human_name %></b>
</p>
<% end
end %>
This topic is locked and can not be replied to.