Answer the question
In order to leave comments, you need to log in
"Custom Environments" to a Ruby on Rails application?
Misters, prompt to the beginner how it is possible to create "user environments"? What do I understand by this. A registered user can add (register) users from his admin panel, assign them rights of different levels (author, reviewer, content manager). Those. so that within one project you can dynamically create users and assign rights to other users.
An example is Pivotal Tracker. Here you can add users to each project, limit their rights. We need some kind of faded semblance.
Answer the question
In order to leave comments, you need to log in
I’m not sure if I understood everything correctly, what you need in the end, but you can implement it as follows:
If you want to bother and write your own authorization, then how to do it from scratch is well described here:
If you are too lazy, then you can use the devise gem ( https://github.com/plataformatec/devise) and, when creating a model, add an additional "role" field to it.
Accordingly, further create the model "Right".
Create a has_and_belongs_to_many relation
For example, your project opens immediately in the edit template
=form_for @project do |f|
какой-то код
=f.collection_select(:permission_ids, Permission.all, :id, :permission_title, {include_blank: false, :include_hidden => false, :selected => @project.permissions.map(&:id)}, { class: 'тут какой-то css', :multiple => true})
=form_for @project do |f|
какой-то код
=f.collection_select(:permission_ids, Permission.all, :id, :permission_title, {include_blank: false, :include_hidden => false, :selected => @project.permissions.map(&:id)}, { class: 'тут какой-то css', :multiple => true})
=f.fields_for :user_permission do |s|
=s.hidden_field :project_id, value: @project.id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question