【发布时间】:2014-03-26 12:27:47
【问题描述】:
您好,我需要使用 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 做些什么感谢您的回答。
【问题讨论】:
-
一个简单的谷歌搜索会立即有所帮助。
标签: ruby-on-rails ruby ruby-on-rails-4 attr-accessible