Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

through current user with singleton resource #338

Open
szimek opened this issue Apr 8, 2011 · 3 comments
Open

through current user with singleton resource #338

szimek opened this issue Apr 8, 2011 · 3 comments
Milestone

Comments

@szimek
Copy link

szimek commented Apr 8, 2011

Hey,

it's rather a question than an issue: I want to load user's profile, which is a singular resource through current user and I have something like this:

load_and_authorize_resource :through => :current_user, :singleton => true

but for new action, it tries to assign profile.current_user = current_user and of course there's no profile.current_user= method. Is there a way to tell it to use user method when assigning parent resource?

@ryanb
Copy link
Owner

ryanb commented Apr 8, 2011

Currently no, but I'll mark further customization to be added along these lines. Right now your best solution is to use a before filter like this.

before_filter :load_user
load_and_authorize_resource :through => :user, :singleton => true

private

def load_user
  @user = current_user
end

@leeatchison
Copy link

Marked for consideration in 2.0.

@xhoy
Copy link

xhoy commented Apr 10, 2014

Dear submitter, Since cancan/raynB hasn't been active for more than 6 months and no body else then ryam himself has commit permissions the cancan project is on a stand still.
Since cancan has several issues including missing support for rails 4 cancan is moving forward to cancancan. More details on: #994

If your feel that your pull request or bug is still applicable (and hasn't been merged in to cancan) it would be really appreciated if you would resubmit it to cancancan (https://github.com/cancancommunity/cancancan)

We hope to see you on the other side!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants