206
207
208
209
210
211
212
213
214
215
216
217
218
|
# File 'lib/generators/leolay/leolay_generator.rb', line 206
def setup_authorization
file = "app/models/ability.rb"
return unless File.exists?(file)
gsub_file file, /initialize(\s|\()user(.|)/, "initialize(#{options[:auth_class].downcase})"
inject_into_file file, :before => " end\nend" do
<<-FILE.gsub(/^ /, '')
#{options[:auth_class].downcase} ||= #{auth_class}.new
can :manage, :all if #{options[:auth_class].downcase}.role? :admin
alias_action :batch_action, :to => :update
can :read, ActiveAdmin::Page, :name => "Dashboard"
FILE
end
end
|