model - Most basic rails controller implementation -
i dont basic implementation.
models
class player < activerecord::base has_one :listing end class listing < activerecord::base belongs_to :player end player controller
def show @player = player.find(params[:id]) @listing = @player.listing.new end routes
resources :listings devise_for :players match "players/:id" => "players#show" error
undefined method `new' nil:nilclass i don't understand why wouldn't create new listing player show page. think routes may need nested doesn't explain error.
i've been @ 2 years , when read guides feel understand completely, when set out on own i'm misunderstanding basic implementation of rendering simple view. out of mind mind frustrated. missing?
the problem @player.listing not set, yet. if making new item on has_one relationship, want use @player.build_listing. http://apidock.com/rails/activerecord/associations/classmethods/has_one
Comments
Post a Comment