user1066183
user1066183

Reputation: 2584

rails+rails admin override action in a controller

i'm using rails_admin gem, is possible to override an action of a specific controller like this:

I'm using the InheritedResources gem by josevalim https://github.com/josevalim/inherited_resources

this is the controller for the "normal" user.

class EventsController < InheritedResources::Base
  load_and_authorize_resource
  def create
    staff=Staff.find(params[:event][:author_id])
    staff.create_user(name: staff.name,email:staff.email) unless staff.user
    create!
  end
end

I want to override the create action of the rails_admin controller for the Event model, as I have just override a "normal" controller. Is possible?

Upvotes: 4

Views: 1796

Answers (1)

Dende
Dende

Reputation: 584

You might want to create a custom action and use it instead of create action. This answer is helpful too. Quote from it:

  • Map a route to your controller & action
  • Have your controller inherit from RailsAdmin MainController and write code for your action
  • Include a view for your action

Upvotes: 1

Related Questions