Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- named_scope :current_selection, :conditions => ['ipayment_confirmed = ? and confirmed = ?', false, false]
- # now this works:
- User.first.checkouts.current_selection
- +----+----------+-----------+-------------------+-------------------+------------------+----------+-----------------+---------+-------------------+-------------------+
- | id | checksum | confirmed | ipayment_id | ipayment_confi... | date_of_purchase | discount | discount_amount | user_id | created_at | updated_at |
- +----+----------+-----------+-------------------+-------------------+------------------+----------+-----------------+---------+-------------------+-------------------+
- | 1 | 111111 | false | ac170c22UD5QnM... | false | 2009-12-07 | false | 0.0 | 1 | Mon Dec 07 18:... | Mon Dec 07 23:... |
- +----+----------+-----------+-------------------+-------------------+------------------+----------+-----------------+---------+-------------------+-------------------+
- 1 row in set
- # but how do use this named_scope in a wrapper method so that i only get the first object back?
- # i tried it like this:
- def current_selection
- scope = self.scoped :conditions => ['ipayment_confirmed = ? and confirmed = ?', false, false]
- scope.first
- end
- # but this doesnt work:
- >> User.first.checkouts.current_selection
- NoMethodError: undefined method `current_selection' for #<Class:0xb6a85bf4>
Add Comment
Please, Sign In to add comment