Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

PIVOTAL LABS
[Standup][NY]09/11/12: CanCan condition hashes)

Interestings

  • CanCan, condition hashes, and index actions

If you have something like:

`can :manage, Group, memberships: { user_id: user.id }`

and:

`class Group < AR::Base
has_many memberships
end
`

you will get duplicate Groups in index action’s @groups ivar when you load_and_authorize (sic) :group as CanCan will do an SQL join of the groups and memberships table.

The solution for us was to use a block and populate the @groups ivar ourselves in the action.

Events

Founded in 2004, NYC.rb is the place for experienced Ruby and Rails programmers in New York City.
MEETUPS
We meet on the second and fourth Tuesdays of the month. Second Tuesdays are for one or more talks, and fourth Tuesdays are just hackfests, where people bring their laptops and hang out.

Comments
Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *