class Object

Public Instance Methods

create() click to toggle source

Redirect to the resource show page after comment creation

# File lib/active_admin/orm/active_record/comments.rb, line 57
def create
  create! do |success, failure|
    success.html{ redirect_to :back }
    failure.html do
      flash[:error] = I18n.t 'active_admin.comments.errors.empty_text'
      redirect_to :back
    end
  end
end
permitted_params() click to toggle source

Define the permitted params in case the app is using Strong Parameters

# File lib/active_admin/orm/active_record/comments.rb, line 68
def permitted_params
  params.permit active_admin_comment: [:body, :namespace, :resource_id, :resource_type]
end
scoped_collection() click to toggle source

Prevent N+1 queries

# File lib/active_admin/orm/active_record/comments.rb, line 52
def scoped_collection
  resource_class.includes :author, :resource
end