Comments (9)
It is now possible to properly remove an action using the remove_action
builder method. Relevant buttons (e.g. save, delete, etc) will also be removed when removing an action.
Usage:
Trestle.resource(:articles) do
remove_action :destroy, :edit, :update
end
from trestle.
Hi, is possible to call remove_action :destroy, :edit, :update inside an if statement? I want to remove actions based on user roles (devise).
Something like:
if not current_user.admin?
remove_action :destroy, :edit, :update
end
Regards,
from trestle.
Yes you can do that
actions do |toolbar, user|
toolbar.edit if user.role_user?
toolbar.delete if user.role_user?
end
from trestle.
OK, I figured out that I could put that 'actions do' block inside 'table do', but not inside the form.
from trestle.
At present, the options are to either make the entire resource read only, using Trestle.resource(:name, readonly: true) do
, or to disable the destroy action using:
controller do
undef_method :destroy
end
However this won't remove the delete links (yet).
I am currently working on an API for custom actions which will allow the default actions to be disabled. I may be able to get that part out sooner than the rest.
from trestle.
Thx! 👍
from trestle.
Using remove_action :show
causes ActionController::UrlGenerationError
.
from trestle.
Workaround for ActionController::UrlGenerationError
when using remove_action :show
:
table autolink: false do
# ...
end
from trestle.
actions do |toolbar, user| toolbar.edit if user.role_user? toolbar.delete if user.role_user? end
Where does that go?
from trestle.
Related Issues (20)
- Listing dates per page HOT 1
- uninitialized constant custom field rails 7 HOT 3
- Changing date format HOT 3
- Option to disable form as "show" view? HOT 1
- My custom helper not is recognized HOT 2
- How i use concerns at trestle? HOT 1
- Remove Multiple Records From MODEL Page
- WebSockets / action_cable support? HOT 2
- Pagination for a custom index View
- Fix typo for Vietnamese locale HOT 1
- Direct upload or chunked file upload support? HOT 2
- Fails without sassc-rails
- Unable to locate favicon.ico in public folder HOT 1
- Best Way To Provide a Select Dropdown for belongs_to that is optional HOT 2
- Filter with a select list
- Enum Radio Button Missing Current Selection HOT 11
- Errors on check_box fields not displaying HOT 2
- Customize navbar HOT 3
- Mongoid support HOT 2
- Use importmap in Trestle HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trestle.