您好,我需要使用 attr_accessible 或类似的东西。我是 Ruby On Rails 的新手
那是我的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 做些什么感谢您的回答。