我想在我的文章中添加作者并且:
unknown attribute: author_id
控制器:
def create
@article = current_user.articles.new(params[:article])
@article.save
flash.notice = "Article '#{@article.title}' Posted!"
redirect_to article_path(@article)
型号1:
class Author < ActiveRecord::Base
authenticates_with_sorcery!
has_many :articles
validates_confirmation_of :password, message: "should match confirmation", if: :password
end
型号2:
class Article < ActiveRecord::Base
attr_accessible :title, :body, :tag_list, :image
belongs_to :author
has_many :taggings
has_many :tags, through: :taggings
has_attached_file :image, :default_url => '/no_image.jpg'
end
可悲的是我不知道出了什么问题
////
在文章模型中你应该使用 author_id 因为作者有很多文章。user_id 将用于将每篇文章指向特定作者
现在我得到了这个:
uninitialized constant Article::AuthorId