On 19 June 2012 13:38, Timen E. <[email protected]> wrote:
> I seem to have it up and running at this point. I made all the
> has_many's etc. in my models. But when i try @cards.user (Or each it
> first and use c.user) it says 'undefined method 'user''. So i'm assuming
> i'm doing something awfully wrong.
>
> My card_controller looks like this
> def show
>    @cards = Card.all
>  end
>
>
>
> Here are my models:
> card.rb
> class Card < ActiveRecord::Base
>    has_many :cardlevels
>  has_many :users, :through => :cardlevels
> end
> -------------------------------------------------
>
> cardlevel.rb
> class Cardlevel < ActiveRecord::Base
>    belongs_to :users
>  belongs_to :cards

Those should both be singular (:user and :card).  Each cardlevel
belongs to one user and card so they should be singular.

Colin

> end
> -------------------------------------------------
>
> user.rb
> class User < ActiveRecord::Base
>    has_many :cardlevels
>  has_many :cards, :through => :cardlevels
> end
>
> -------------------------------------------------
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> 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 [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to