On 25/05/2009, at 4:30 PM, pepijnloo...@gmail.com wrote:

>
> Hi, I'm also new to rails and I'm trying the same thing. I'm extending
> the Getting Started example to learn.
>
> I've made an extra table called `clients`: (id | name) and I already
> had the table `posts`: (id | title | content | created_at | updated_at
> | client_id). The index view for posts loops through all the posts I
> want to show the client name. I believe the way to do this is like
> this:
>
> <% @posts.each do |post| %>
>  <tr>
>    <td><%=h post.client.name %></td>
>    <td><%=h post.title %></td>
>    [...]
>
> I have set up all the assocations (posts belongs_to client, client
> has_many posts) but it doesn't work. I'm probably making a simple
> mistake but hey, I'm new :)
>
> Thanks in advance.
>

How does it fail? What error messages does it give?
Please send us your full model code

When asking for help, it's best to give as much context as possible.

Check out my free videos at http://sensei.zenunit.com . They may help.

Julian.

----------------------------------------------
Learn: http://sensei.zenunit.com/
Last updated 20-May-09 (Rails, Basic Unix)
Blog: http://random8.zenunit.com/
Twitter: http://twitter.com/random8r


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to