class User < ActiveRecord::Base
has_many :ties, dependent: :destroy
has_many :albums, through: :ties
end
class Album < ActiveRecord::Base
has_many :ties, dependent: :destroy
has_many :users, through: :ties
end
class Tie < ActiveRecord::Base
belongs_to :user
belongs_to :album, dependent: :destroy
end
K...だから、 AlbumsController#Create アクションから、アルバムを作成しようとすると:
def create
@album = current_user.albums.build(params[:album]) #error is on this line
if @album.save
flash[:success] = "#{@album.description} created!"
redirect_to @album
else
flash[:error] = 'Looks like something was invalid with that album. Try again.'
redirect_to albums_path
end
end
私は得てuninitialized constant User::Ty
います。Tie
Rails は と紛らわしいと思いますTy
。何か案が?から特定の名前を強制できますen.yml
か?