【发布时间】:2012-05-09 22:53:40
【问题描述】:
我正在使用 Ruby 1.9 在 RoR 3.1 上开发一个网站。 我想为这样的用户角色创建一个配置文件(RAILS_ROOT/config/roles.rb):
auth do
roles :admin do
auth_on :blogs, :to => [:create, update, :destroy]
auth_on :comments, :to => [:create, update, :destroy]
end
roles :moderator do
auth_on :blogs, :to => [update]
auth_on :comments, :to => [:create, update] do
where_attribute :user => current_user
end
end
end
这个想法是解析文件并为角色设置变量。您知道如何实现这种帮助程序以及如何逐块解析文件吗?如果您对创建一个简单的配置文件有其他想法,请告诉我!
【问题讨论】:
标签: ruby-on-rails ruby helpers