# Displaying find.all from another view

**URL:** <https://www.ruby-forum.com/t/displaying-find-all-from-another-view/87720>\
**Category:** Rails\
**Created:** [March 5, 2007, 4:03pm UTC](https://www.ruby-forum.com/t/displaying-find-all-from-another-view/87720 "2007-03-05T16:03:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dfb087/32.png) [@stevep](https://www.ruby-forum.com/u/stevep)\
**Post date:** [March 5, 2007, 4:03pm UTC](https://www.ruby-forum.com/t/displaying-find-all-from-another-view/87720/1 "2007-03-05T16:03:29Z")

</div>

I’ve got 2 controllers - user and club

I want to display all the clubs in a user view, how would i go about it?

All i seem to get is NoMethodError

---

<div class="post-metadata">

**Author:** ![stevep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dfb087/32.png) [@stevep](https://www.ruby-forum.com/u/stevep)\
**Post date:** [March 5, 2007, 4:38pm UTC](https://www.ruby-forum.com/t/displaying-find-all-from-another-view/87720/2 "2007-03-05T16:38:54Z")

</div>

Well, how are you currently going about it? Is Club.find\_all not  
working?

Jason

---

<div class="post-metadata">

**Author:** ![stevep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dfb087/32.png) [@stevep](https://www.ruby-forum.com/u/stevep)\
**Post date:** [March 5, 2007, 4:56pm UTC](https://www.ruby-forum.com/t/displaying-find-all-from-another-view/87720/3 "2007-03-05T16:56:52Z")

</div>

At the moment in the users controller i have:

def club  
@club = Club.find\_all  
end

then in the user view (index) i have:

\<% for user in @users %\>

\<%= club.id %\>  
\<%= club.name %\>

\<% end %\>

Am I going around it completely the wrong way? 😑

---

<div class="post-metadata">

**Author:** ![stevep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dfb087/32.png) [@stevep](https://www.ruby-forum.com/u/stevep)\
**Post date:** [March 5, 2007, 5:34pm UTC](https://www.ruby-forum.com/t/displaying-find-all-from-another-view/87720/4 "2007-03-05T17:34:59Z")

</div>

It’s ok I’ve sorted it! It was me being a silly git!

---

<div class="post-metadata">

**Author:** ![stevep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dfb087/32.png) [@stevep](https://www.ruby-forum.com/u/stevep)\
**Post date:** [March 5, 2007, 6:02pm UTC](https://www.ruby-forum.com/t/displaying-find-all-from-another-view/87720/5 "2007-03-05T18:02:15Z")

</div>

Looks like you’re still not quite grasping what Controller classes are.  
def  
club; … end; is an action, code that will only be called when you  
POST/GET  
to /users/club. Looks like you want just /users/, so your index action  
(def  
index; … end;) is the one that should contain @club = Club.find\_all.

Of course, the view is wrong as well.

Controller:

def index  
@user = [user stuff]  
@clubs = Club.find\_all  
end

View:

\<% for club in @clubs %\>  
\<%= club.id %\>  
\<%= club.name %\>  
\<% end %\>

You should spend some more time looking through documentation on how to  
use  
Rails. The Agile Development with Rails is an excellent book to get you  
started.

Jason
