How to configure/exclude actions?

1,281 views
Skip to first unread message

Eckhard Rotte

unread,
Aug 19, 2013, 6:29:12 PM8/19/13
to rails...@googlegroups.com
Hi,
RailsAdmin is awesome, but I have a little problem:

I want to exclude default actions like :edit or :delete or  'show in Application' on a global or per model base.

The Actions Page in the Wiki includes a lot of information about adding custom actions, but theres no information about hiding default actions. 


The example for customisation does not work and throws an error ("[action] already exists")

There's some more info in the wiki which may be outdated or I simply do not understand, e.g. this:
This may help but – where do I have to add those action blocks?

I would like to do something like this:

config.model 'Model' do
  edit {hide}
  new {hide}
  // or
  actions.exclude [:new, edit]
  end
end
 
ReadOnly-Models would also be a proper solution, but read-only is implemented per attribute.

I also don't want to use CanCan because i don't need authorisation here.

Either I am totally stupid or - is it really so hard to configure rails_admin actions?

I'm running Rails 4 with rails_admin 0.5.0.
 

greetings,
ecki

Ganesh Kuwar

unread,
Aug 20, 2013, 12:12:41 AM8/20/13
to rails...@googlegroups.com
You can exclude some action using cancan for rails admin. 
For example: If you want to hide edit and new action of model 'Model' then add
cannot :edit, Model 
cannot :new, Model
within ability.

 


--
You received this message because you are subscribed to the Google Groups "rails_admin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rails_admin...@googlegroups.com.
To post to this group, send email to rails...@googlegroups.com.
Visit this group at http://groups.google.com/group/rails_admin.
For more options, visit https://groups.google.com/groups/opt_out.



--
With Regards,
Ganesh Kunwar
Ruby Team
E-signature

Eckhard Rotte

unread,
Aug 20, 2013, 5:13:50 AM8/20/13
to rails...@googlegroups.com
Ok, so the answer is: 

There's no simple option to configure the visibility of actions.

I have to use CanCan, which I don't need. 
Or I have to implement a custom action with custom views.

Am I right?


regards,
Ecki

Ganesh Kuwar

unread,
Aug 20, 2013, 5:25:38 AM8/20/13
to rails...@googlegroups.com
If you want to configure the visibility of action, the better idea is using cancan instead of custom action. For detail you can see: https://github.com/sferik/rails_admin/wiki/CanCan 

Eckhard Rotte

unread,
Aug 20, 2013, 5:39:32 AM8/20/13
to rails...@googlegroups.com
Ok, I simply wanted to mention that there's no simple config option to configure this and the docs are outdated and misleading in some cases.
I"ll create an issue on Github.


thanks a lot!
Ecki

You received this message because you are subscribed to a topic in the Google Groups "rails_admin" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rails_admin/XoltZUvLXnA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rails_admin...@googlegroups.com.
signature.asc

Sergey Belotelkin

unread,
Aug 1, 2014, 5:14:37 AM8/1/14
to rails...@googlegroups.com
You can do this without cancan

config.actions do
  new do
    except [ModelName]
  end
  edit do
    except [ModelName]
  end
end

вторник, 20 августа 2013 г., 2:29:12 UTC+4 пользователь Eckhard Rotte написал:
Reply all
Reply to author
Forward
0 new messages