你好,我需要使用attr_accessible或類似that.And我是新的Ruby on Rails的attr_accessible爲Rails 4
這是我post.rb
文件
class Post < ActiveRecord::Base
has_many :comments
attr_accessible :body, :title, :published, :author, :author_id
belongs_to :author, :class_name => "AdminUser"
validates_presence_of :body,:title
scope :published, where(:published => true)
def content
MarkdownService.new.render(body)
end
def author_name
if author
author.name
else
"Nobody"
end
end
end
我能爲attr_accesible感謝做你的答案。
一個簡單的谷歌搜索會馬上幫助。 –