Rails: activeadmin overriding create action Rails: activeadmin overriding create action ruby-on-rails ruby-on-rails

Rails: activeadmin overriding create action


I ran into a similar situation where I didn't really need to completely override the create method. I really only wanted to inject properties before save, and only on create; very similar to your example. After reading through the ActiveAdmin source, I determined that I could use before_create to do what I needed:

ActiveAdmin.register Product do  before_create do |product|    product.creator = current_user  endend


Another option:

def create  params[:item].merge!({ user_id: current_curator.id })  create!end


You are right active admin use InheritedResources, all other tools you can see on the end of the page.