-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overriding existing CRUD action for specific model #1855
Comments
+1 #1865 or maybe use an AR observer : http://api.rubyonrails.org/v3.2.15/classes/ActiveRecord/Observer.html |
it works with AR observer , but AR Observers officially deprecated in Rails 4.0, i think it's not a good (clean) solution. |
i have same problem |
Same issue here. I use a service object in the application and calling it from the admin would avoid ugly hacks :/ |
If you are using the authorization layer (I am using Pundit), you can create a custom policy, that will allow you to override as much as possible.
Using the pundit, add in your policy class a method like this:
|
I'd like to set an attribute, based on the current user, before the model is created. I've reviewed https://github.com/sferik/rails_admin/wiki/How-to-set-default-values and https://github.com/sferik/rails_admin/wiki/How-to-set-current_user-to-the-field, but I would like to do it during the
#create
action in the controller to prevent tampering. I saw a similar request at #756, but that was closed with the note "Closing because custom actions are already implemented." Ideally I'd just like to override the default create action to set the field and then callsuper
to finish the processing. Is that possible, or do I need to impliment a custom action for this? And if so, how do I use that as the default create action for this particular model? Can you point me at an example?The text was updated successfully, but these errors were encountered: