Comments (6)
Hello! Give me a time to analyze your situation. I'll try to help
from the_role.
I didn't mean to to upset you.
I'm rather new to Github and I was under the impression that this is the way to ask questions.
Sorry
from the_role.
I think, in code your situation looks like that:
class User < AR
has_many :expense_reports
end
class ExpenseReport < AR
belongs_to :user
end
and I think you want to render list of expense_reports of user (for example with ID 567) with URL
/users/567/expense_reports
You should not to check ownership of user to each object (@owner_check_object can't to help you). Because you should only render a list of expense_reports of this current_user
This story out of scope of TheRole. TheRole should not to resolve situation when User 1 try to see Index action of User 2. That is why you cant to find solution in TheRole documentaion.
This situation should be resolved manually with your code. There is part of my current project
class ApplicationController < ActionController::Base
before_action :define_user
private
def define_user
@root = User.root
@user = current_user
user_id = params[:user_id]
@user = User.find(user_id) if user_id
end
class PagesController < ActionController::Base
before_action :check_for_list_owner, only: [:manage]
def manage; end
private
def check_for_list_owner
unless (current_user == @user || current_user.admin?)
redirect_to root_path, flash: { error: "Access denide" }
end
end
end
Can it be solution for your story?
from the_role.
Yes.
This is what I was looking for.
I can protect all the user's nested objects with this solution.
Thanks man!
from the_role.
@danevron he is not upset just Russian. ;)
from the_role.
@seuros 😄
from the_role.
Related Issues (20)
- Rails 4.1 compatibility HOT 10
- `create_section': undefined method `[]' for nil:NilClass (NoMethodError) HOT 2
- The rule for admin role is empty HOT 6
- Several Issues - the instructions say one thing generator does another HOT 3
- undefined method `authenticate_user!' HOT 7
- Cannot define multiple included blocks for a Concern HOT 7
- I18n::MissingTranslationData in Admin::Roles#index HOT 4
- unable to open selection from comboBox for enable/disable a rule HOT 3
- an error when try to ask for admin role HOT 9
- No route matches [PATCH] "/admin/roles/1/change" HOT 3
- Uncaught TypeError: a_item.hide(...).off is not a function HOT 2
- Rails 5 compatibility? HOT 4
- Migrating existing app to TheRole HOT 1
- Postgres and the role HOT 8
- The title of The Roles admin page shows "TheRoleTestcase" HOT 3
- rails-5, ruby-2.4 HOT 3
- Not an issue, but a possible fork? HOT 5
- cannot load such file -- the_string_to_slug (LoadError) HOT 3
- Planing to support rails 7? HOT 17
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 the_role.