Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

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

Danny Gagne
Tuesday, September 11, 2012

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

  • Tuesday: NYC.rb Presentation Night
    http://www.meetup.com/NYC-rb/

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.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Add New Comment Cancel reply

Your email address will not be published.

Danny Gagne

Danny Gagne
New York

Recent Posts

  • [Standup][NY] 9/10/12: Debugging CoffeeScript in Chrome
Subscribe to Danny's Feed

Author Topics

agile (2)
coffeescript (1)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >