209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/admin_assistant.rb', line 209
def admin_assistant_for(model_class, &block)
begin
self.admin_assistant = AdminAssistant.new(self, model_class)
builder = Builder.new self.admin_assistant
if block
block.call builder
end
self.helper AdminAssistant::Helper
self.admin_assistant.controller_actions.each do |action|
self.send(:define_method, action) do
self.class.admin_assistant.send(action, self)
end
end
AdminAssistant.routes << Route.new(self.admin_assistant)
rescue ActiveRecord::StatementInvalid, Mysql::Error
Rails.logger.info "Skipping admin_assistant_for for #{self.name} because the table doesn't exist in the DB. Hopefully that's because you're deploying with a migration."
end
end
|