calm-gold-48525
06/08/2023, 10:22 PMloud-jewelry-99127
06/08/2023, 10:25 PMloud-jewelry-99127
06/08/2023, 10:26 PMcalm-gold-48525
06/08/2023, 10:27 PMloud-jewelry-99127
06/08/2023, 10:28 PMcalm-gold-48525
06/08/2023, 10:28 PMloud-jewelry-99127
06/08/2023, 10:29 PMcalm-gold-48525
06/08/2023, 10:31 PMloud-jewelry-99127
06/08/2023, 10:32 PMcalm-gold-48525
06/08/2023, 10:32 PMloud-jewelry-99127
06/08/2023, 11:22 PMindex
edit
show
etc.. methods on the let's say avo books controller and call super if user is admin or redirect it to a more restrictive resource if another role, you can even do a switch and redirect each role to a diferent resource.
You can also use I18n to make all resources be called as "Book" and it will be clean and elegant.loud-jewelry-99127
06/08/2023, 11:23 PMloud-jewelry-99127
06/08/2023, 11:29 PMruby
class Avo::BooksController < Avo::ResourcesController
def index
if current_user.is_admin?
super
else
redirect_to resources_limited_editor_books_path
end
end
def edit
if current_user.is_admin?
super
else
redirect_to resources_limited_editor_books_path(id: params[:id])
end
end
end
you can apply this logic to update
show
new
create
destroy
if necessary (with the adequate path helpers)loud-jewelry-99127
06/08/2023, 11:38 PMlemon-wall-20836
06/09/2023, 7:27 AMlemon-wall-20836
06/09/2023, 7:27 AMlemon-wall-20836
06/09/2023, 7:27 AMlemon-wall-20836
06/09/2023, 7:28 AMlemon-wall-20836
06/09/2023, 7:38 AMlemon-wall-20836
06/09/2023, 7:48 AMbooks
the main BookResource
will be used. you can use the use_resource
option to specify the resource based on the rolecalm-gold-48525
06/09/2023, 9:53 PMcalm-gold-48525
06/14/2023, 4:59 PMlemon-wall-20836
06/14/2023, 5:00 PM