The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Exclusive Conditions for ActiveRecord's has_many

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jason Perry

Posts: 34
Nickname: ambethia
Registered: Jul, 2007

Jason Perry is rubyist and lead developer for The Inspirit, LLC
Exclusive Conditions for ActiveRecord's has_many Posted: Nov 28, 2007 9:56 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jason Perry.
Original Post: Exclusive Conditions for ActiveRecord's has_many
Feed Title: Ambethia
Feed URL: http://ambethia.com/feed
Feed Description: The journal and personal website of Jason L Perry, dealing in development, design and distractions.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jason Perry
Latest Posts From Ambethia

Advertisement
I’ll start with some code. class User < ActiveRecord::Base has_many :things, :exclusive_conditions => %q(`things`.user_id = #{id} OR #{admin?}) end Assuming, we have 2 users, Alice and Bob. user = User.find_by_username("alice") # => Alice is an admin. user.id # => 1 thing = user.things.find_by_name("Bob's Thing") thing.user_id # => 2, It's still bobs thing. Now in my controller’s I can just say something like: class [...]

Read: Exclusive Conditions for ActiveRecord's has_many

Topic: Rucola 0.0.2 released! Previous Topic   Next Topic Topic: Firefox 2.0 Phishing Protection

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use