文章列表
想用 method_missing构造动态方法,以"can_" 开头
ruby 代码
class User < ActiveRecord::Base
def has_role?(role_in_question)
@_list ||= self.roles.collect(&:name)
return true if @_list.include?("admin")
(@_list.include?(role_in_question.to_s ...