Wednesday, June 20, 2012

Re: [Rails] Re: Associations join

On 20 June 2012 08:51, Timen E. <lists@ruby-forum.com> wrote:
> #card_controller.rb
> class CardController < ApplicationController
>  def show
>    @card = Card.all
>  end
> end
>
> <h1>Card#show</h1>
> <p>Find me in app/views/card/show.html.erb</p>
> <%= @card.user %>
>
> undefined method `user' for #<Array:0x3c81ac8>
> Extracted source (around line #3):

@card is a collection of cards (that's how you populate it in the
"show" action. If it needs to be a single card, you need to find it by
ID (or some other attribute), if it's supposed to be a collection of
every card, you need to iterate it in the view and print the user for
each card.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate