named-scope
Using a Rails scope as a proxy for the scope of a related object
In our application we have two models, Stores and Offers. Stores are geocoded using the \'geocoder\' gem[详细]
2023-03-20 03:32 分类:问答Using RSpec to test active record scope that uses the includes method
Given the following two classes: class Location < ActiveRecord::Base belongs_to :holiday_schedule validates :name, :presence => true, :uniqueness => {:case_sensitive => false}[详细]
2023-03-19 12:16 分类:问答Better way to write named scope?
This named scope is working fine. named_scope :search, lambda {|search_txt| { :conditions => [\"field1 like ? or field2 like ? or field3 like ?\",\"#{search_txt}%\",\"#{search_txt}%\",\"#{search_t[详细]
2023-03-17 07:21 分类:问答Null property selection using named scopes/lambda in Ruby on Rails
I have an object JobBreakdown that has_one :invoice.If a JobBreakdown has an invoice (i.e. invoice_id is not nil) 开发者_运维知识库then it is considered INVOICED.If not, it is consider UNINVOICED.User[详细]
2023-03-16 10:49 分类:问答Converting method to scope in Rails 3
I\'d like to convert this method to a scope in rails so I could call something like Batch.all_completed and it would return all batches that met the criteria in the method:[详细]
2023-03-16 05:10 分类:问答How to DRY named_scope extension
Given the following code: named_scope :by_order, :order => \'priority ASC\' do def total_points self.sum(\'point_value\')[详细]
2023-03-15 08:56 分类:问答Mongoid Scope order by syntax please
I\'m using the latest mongoid... How do I do the mongoid equivalent of this active record named_scope:[详细]
2023-03-12 12:04 分类:问答named_scope and .first?
I can return a collection of objects, with only one (:limit => 1) but is there a way to return the .first() object only, like not within a collection?[详细]
2023-03-12 00:36 分类:问答Rails 2.3.8 named_scope chaining
I have the following nested if statement hairball, I\'m wondering if there is a more efficient way of writing this code (less lines of code that doesn\'t require so many conditionals)[详细]
2023-03-10 22:43 分类:问答Rails 3: How to create a named scope based on Controller's method?
In my ApplicationController I have the demo_mode? method (which returns true when the currently logged in user type is \"demo\").[详细]
2023-03-07 18:46 分类:问答
加载中,请稍侯......