Hi, when I exclude a model from new action RailsAdmin should disallow its creation in any way across the whole admin interface.
RailsAdmin instead allows to create excluded models through association fields (it lets you open a modal fill all fields and save it) and just raises an un-handled error for breadcrumbs when you hit "save and add another" button.
This is pretty annoying and while you can disable 'inline_add' for associations it forces you to resort to authorization to hide the 'add_another' button.
The worst part is that controller actions aren't disabled: I can point the browser to new action path for a model and it always responds with the form. I've not tried but that makes me guess that I can destroy a model excluded from 'delete' action as well.
I think this should be fixed or documented someway.
Anyway I hate having to setup authorization for tasks like hiding a button. Especially if authorization Is not an app requirement (i.e nobody should be able to create a model no matter who he is).
The ideal solution would be to just disallow routes for disabled actions and change the authorized? helper to check also if @abstract_model class is enabled for that action or not.
Something like:
def authorized?(action_name, model)
action_object = RailsAdmin::Config::Action.all.find {|a| a.action_name.to_s == action.to_s}
if action_object && action_object.exclude.include?(model.model.name)
return false
else
super(action, model)
end
end
Thank you very much anyway,
if you wish to fix this I can look at the code deeper and help with a PR.
Just let me know.
Hi, when I exclude a model from new action RailsAdmin should disallow its creation in any way across the whole admin interface.
RailsAdmin instead allows to create excluded models through association fields (it lets you open a modal fill all fields and save it) and just raises an un-handled error for breadcrumbs when you hit "save and add another" button.
This is pretty annoying and while you can disable 'inline_add' for associations it forces you to resort to authorization to hide the 'add_another' button.
The worst part is that controller actions aren't disabled: I can point the browser to new action path for a model and it always responds with the form. I've not tried but that makes me guess that I can destroy a model excluded from 'delete' action as well.
I think this should be fixed or documented someway.
Anyway I hate having to setup authorization for tasks like hiding a button. Especially if authorization Is not an app requirement (i.e nobody should be able to create a model no matter who he is).
The ideal solution would be to just disallow routes for disabled actions and change the
authorized?helper to check also if @abstract_model class is enabled for that action or not.Something like:
Thank you very much anyway,
if you wish to fix this I can look at the code deeper and help with a PR.
Just let me know.