# Customising 'show'

**URL:** <https://www.ruby-forum.com/t/customising-show/63456>\
**Category:** Rails\
**Created:** [June 15, 2006, 11:37am UTC](https://www.ruby-forum.com/t/customising-show/63456 "2006-06-15T11:37:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rebecca\_cannon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@rebecca\_cannon](https://www.ruby-forum.com/u/rebecca_cannon)\
**Post date:** [June 15, 2006, 11:37am UTC](https://www.ruby-forum.com/t/customising-show/63456/1 "2006-06-15T11:37:20Z")

</div>

Newb here;

I feel like im cheating when i actually write to the list, but i’ve  
been stuck on this for a while now and cant seem to find the answer in  
tutorials… heres the simplified version of the problem

controller says:

def show  
@exhibition = Exhibition.find(params[:id])  
end

content says:

\<% for exhibition in @exhibitions %\>  
\<%= link\_to ‘Details’,  
{:action =\> ‘show’, :id =\> exhibition.id }, :class =\> ‘show’ %\>  
\<% end %\>

linked to show template code says:  
\<%= h(@exhibition.gallery) %\>  
\<%= link\_to ‘Back’, :action =\> ‘index’ %\>

clicking the show link works: in that i get a page and the url has  
/show/3 - so the model id has been parsed through…  
however the exhibition.gallery isn’t showing up on the page. the back  
link is working.

i’m sure i’ve missed something in the ‘show’ template, but i have no  
idea what it is

thanks for your time…

---

<div class="post-metadata">

**Author:** ![rebecca\_cannon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@rebecca\_cannon](https://www.ruby-forum.com/u/rebecca_cannon)\
**Post date:** [June 15, 2006, 11:49am UTC](https://www.ruby-forum.com/t/customising-show/63456/2 "2006-06-15T11:49:21Z")

</div>

rebecca cannon wrote:

> however the exhibition.gallery isn’t showing up on the page. the back  
> link is working.
> 
> i’m sure i’ve missed something in the ‘show’ template, but i have no  
> idea what it is

Hi Rebecca,

Some things to try and questions.

- If you do a “view source” is there anything there at all ?
- Is gallery a string or an associated model?
- If you put \<%= @exhibition.id %\> into your show template do you see  
that ? (or any other field)
- Can you show us your Exhibition model code ?

Alan

---

<div class="post-metadata">

**Author:** ![rebecca\_cannon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@rebecca\_cannon](https://www.ruby-forum.com/u/rebecca_cannon)\
**Post date:** [June 15, 2006, 1:15pm UTC](https://www.ruby-forum.com/t/customising-show/63456/3 "2006-06-15T13:15:28Z")

</div>

Hi Rebecca,

rebecca cannon wrote:

> {:action =\> ‘show’, :id =\> exhibition.id }, :class =\> ‘show’ %\>  
> \<% end %\>
> 
> linked to show template code says:  
> \<%= h(@exhibition.gallery) %\>  
> \<%= link\_to ‘Back’, :action =\> ‘index’ %\>
> 
> clicking the show link works: in that i get a page and the url has  
> /show/3 - so the model id has been parsed through…  
> however the exhibition.gallery isn’t showing up on the page. the back  
> link is working.

Have you checked the database (i.e., using something like MySQL-Front)  
to  
verify that the gallery column contains the content you expect?

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![rebecca\_cannon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@rebecca\_cannon](https://www.ruby-forum.com/u/rebecca_cannon)\
**Post date:** [June 15, 2006, 3:27pm UTC](https://www.ruby-forum.com/t/customising-show/63456/4 "2006-06-15T15:27:27Z")

</div>

Kevin O. wrote:

> > \<%= link\_to ‘Details’,  
> > {:action =\> ‘show’, :id =\> exhibition.id }, :class =\> ‘show’ %\>  
> > \<% end %\>
> 
> the controller should be:
> 
> def show  
> @exhibitions = Exhibition.find(params[:id])  
> end
> 
> Note the plural form of exhibition.
> 
> \_Kevin

I don’t think so. I think the index action (which we didn’t see) was  
giving the plural, which was iterated over (in the first template) to  
give the link to show. The show action (correctly) gave the singular.

Alan

---

<div class="post-metadata">

**Author:** ![rebecca\_cannon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@rebecca\_cannon](https://www.ruby-forum.com/u/rebecca_cannon)\
**Post date:** [June 15, 2006, 2:22pm UTC](https://www.ruby-forum.com/t/customising-show/63456/5 "2006-06-15T14:22:10Z")

</div>

> \<%= link\_to ‘Details’,  
> {:action =\> ‘show’, :id =\> exhibition.id }, :class =\> ‘show’ %\>  
> \<% end %\>

the controller should be:

def show  
@exhibitions = Exhibition.find(params[:id])  
end

Note the plural form of exhibition.

\_Kevin

---

<div class="post-metadata">

**Author:** ![rebecca\_cannon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@rebecca\_cannon](https://www.ruby-forum.com/u/rebecca_cannon)\
**Post date:** [June 15, 2006, 5:07pm UTC](https://www.ruby-forum.com/t/customising-show/63456/6 "2006-06-15T17:07:37Z")

</div>

Alan F. wrote:

> > Note the plural form of exhibition.
> > 
> > \_Kevin
> 
> I don’t think so. I think the index action (which we didn’t see) was  
> giving the plural, which was iterated over (in the first template) to  
> give the link to show. The show action (correctly) gave the singular.
> 
> Alan

At the risk of grossly overstepping by bounds as a Rails noob myself, I  
think Kevin is at least partly right. Rebecca’s show method in the  
controller is assigning to @exhibition (singular) and the use of .find  
suggests to me that she’s lookup up a single exhibition by it’s id (3).  
However, her view is calling @exhibitions (plural) in a for loop, which  
implies multiple exhibitions in an array. Which is wrong depends on what  
she expects to see on the page, a single exhibition, or a list of  
several.

## – Jonathan M. Web D. WW IDEA [http://www.wwidea.org](http://www.wwidea.org) 929 SW Higgins Ave, Suite B Missoula, MT 59803 406-542-3334

“Next time you get an email telling you  
to forward it to everyone you know…  
pretend you don’t know me.” ~ Anonymous

---

<div class="post-metadata">

**Author:** ![rebecca\_cannon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7feea3/32.png) [@rebecca\_cannon](https://www.ruby-forum.com/u/rebecca_cannon)\
**Post date:** [June 16, 2006, 12:40pm UTC](https://www.ruby-forum.com/t/customising-show/63456/7 "2006-06-16T12:40:40Z")

</div>

Jonathan M. wrote:

> Rebecca’s show method in the  
> controller is assigning to @exhibition (singular) and the use of .find  
> suggests to me that she’s lookup up a single exhibition by it’s id (3).  
> However, her view is calling @exhibitions (plural) in a for loop, which  
> implies multiple exhibitions in an array. Which is wrong depends on what  
> she expects to see on the page, a single exhibition, or a list of  
> several.

It’s two different action/view combos. There’s an index action (which  
we haven’t yet seen) which will do a @exhibitions =  
Exhibition.find(:all). This leads to the index.rhtml file which has the  
loop we _have_ seen. The body of that loop sets up a show link for a  
single exhibition. The show link triggers the show action (which we  
have also seen) and that contains single find for the requested  
exhibition. This in turns trigger the show.rhtml template (which again,  
we have seen).

This is just basic, default, generated scaffolding.

The only thing thats different is specifying @exhibition.gallery  
directly instead of the dynamic looping over columns that we normally  
see in the show.rhtml file. That’s where the problem seems to be and I  
think the singular/plural thing is clouding the issue.

Alan

Alan
