class Object
Public Instance Methods
create()
click to toggle source
Redirect to the resource show page after comment creation
# File lib/active_admin/comments.rb, line 53 def create create! do |success, failure| # FYI: below we call `resource.resource`. First is the comment, second is the associated resource. resource_config = active_admin_config.namespace.resource_for resource.resource.class resource_url = resource_config.route_instance_path resource.resource success.html{ redirect_to resource_url } failure.html do flash[:error] = I18n.t('active_admin.comments.errors.empty_text') redirect_to resource_url 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/comments.rb, line 67 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/comments.rb, line 48 def scoped_collection resource_class.includes :author, :resource end