search for: named_scop

Displaying 20 results from an estimated 37 matches for "named_scop".

Did you mean: named_scope
2009 Jul 23
11
Problem with named_scope
Here are my scopes: default_scope :order => ''posted_on DESC'', :conditions => { :status => ''visible'' } named_scope :positive, :conditions => { :rating => ''positive'', :status => ''visible'' } named_scope :neutral, :conditions => { :rating => ''neutral'', :status => ''visible'' } named_scope :negative, :conditions => { :ra...
2010 Sep 01
4
deprecation warning in Rails 3 about Base.named_scope
I recently upgraded to Rails 3, and this error has come up ubiquitously: DEPRECATION WARNING: Base.named_scope has been deprecated, please use Base.scope instead. Any ideas on how to get rid of it? Or should I just wait for something? There''s actually no place in my application where the code "Base.named_scope" exists, so I assume the problem is inherent in gems that haven''t g...
2008 Apr 04
0
named_scope and ordering
Hi, this is a general design question and I liked to see how other people handle the following situation: Before named_scope I wrote custom finders for my model classes. Something like # order.rb class Order < ActiveRecord::Base class << self def find_all_marked find(:all, :conditions => {:marked => 1}, :order => ''name ASC'') end end end Now this can easily be refac...
2010 Mar 09
1
Ruby 1.9 and Searchlogic problem
Hello, After updating our Rails app to ruby 1.9 there are some problems with searchlogic, here you can find the error : Error : wrong number of arguments (1 for 0) Full trace ( passenger ) : /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/named_scope.rb:92:in `call'' /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/named_scope.rb:92:in `block in named_scope'' /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-2.3.5/lib/active_record/named_scope.rb:97:in `call'' /usr/local/lib/ruby/gems/1.9.1/gems/a...
2010 Jan 15
1
Chaining queries in ActiveRecord
Hi all, Stuck at this problem for several days. Tried to use named_scope, scope_out, and plugin such as searchlogic, but no result. The problem is as follows: I have a pic table and tag table, and a join table called pic_tag (with only pic_id and tag_id) so that I can associate N pics to M tags. This is the tutorial way to set up a many- to-many association. I'...
2009 Jul 11
2
offeride :limit named_scope default_scope
Hi, Rails 2.3.2 class TestD < ActiveRecord::Base default_scope :limit => 12 named_scope :limit, lambda { |num| { :limit => num} } end ruby script/console >> TestD.all TestD Load (0.7ms) SELECT * FROM "test_ds" LIMIT 12 => [] >> TestD.limit(14) TestD Load (0.3ms) SELECT * FROM "test_ds" LIMIT 12 => [] Any ideas why the default limit...
2008 Jun 12
0
named_scope doesn''t check for critical method names.
I just entered this ticket. http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/404-named_scope-bashes-critical-methods It turns out that in an ActiveRecord model like this Model << ActiveRecord::Base named_scope :public private def private_method end public def public_method end end The method public_method will be private because named scope overrides Ruby&...
2010 Nov 03
0
Accessing (updating?) the proxy_scope chain for named_scope (Rails 2.3.x)
I have many named_scopes chained together in the normal way. So far so good. However in a couple of cases where: 1. The named scope is actually a correlated subquery and I need to pass additional scope into it sometimes. 2. Where the presence of a named scope in the chain should change the behaviour of a named_sco...
2008 Jun 12
0
Mysterious interaction between RSpec 1.1.4 and has_finder/named_scope
I just opened a Rails ticket on a problem with named_scope in Rails 2.1, and cross-posted a message here which I send to rails-core. I''m still a bit mystified, because I''m having a problem caused by this on RSpec 1.1.4, but not on 1.1.3, and I don''t see a difference in code which would explain it. The basic problem, which I en...
2009 May 12
4
has_many :through and scopes: how to mutate the set of associated objects?
I have a model layer containing Movie, Person, Role, and RoleType, making it possible to express facts such as "Clint Easterbunny is director of the movie Gran Milano". The relevant model and associations look like this class Movie < ActiveRecord::Base has_many :roles, :include => :role_type, :dependent => :destroy has_many :participants, :through => :roles, :source
2008 Jul 20
0
eager loading a named_scope
Hi, I''d like to eager load a named_scope like this: User.find(params[:id], :include => [:friends.married]) Any ideas? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...
2010 Apr 07
3
Recommendation for searching with regards to timestamp & foreign key attributes
hi guys, I need a recommendation for searching with regards to timestamp & foreign key attributes. Sounds a bit too much but here''s an example. Suppose we have a "blog" object. It has many attributes such as - title - content - status_id - created_at - updated_at There are also "status" objects which have the following statuses, "new",
2010 Jan 05
2
Conditional named_scope chaining with params (Need help)
Hello there, I have a model that has more then one named_scope. In my action Index of the controller that handle this model I want to do this in a drier way: if params[:ownership] == "mine" @posts = Post.tagged_with(params[:tags], :on => :tags).owner(current_user.id).paginate :all, :page => params[:page], :order => ''c...
2008 May 13
6
Testing that named_scope is defined
Hi guys, I''m just beginning to use RSpec and I ran into the issue of testing a named_scope. I''m not actually trying to test its behavior, as it''s not my code, but I wanted to test at least that it''s defined. I tried doing this: describe Post, ".most_recent" do it "should be defined" do Post.method_defined?(:most_recent).should be_tru...
2010 Jul 07
1
Ticket 5063: Typo in named_scope in activerecord tests category.rb
Hey all, Does someone want to look over a super-trivial patch I just submitted? It''s just correcting a typo; someone accidentally spelled "group_by_title" as "gruop_by_title" in the category.rb model in the activerecord tests. I just fixed it in the model, and in the two places it''s referenced in the habtm test. Thanks, Ben -- You received this message
2010 Mar 01
0
undefined method for Polymorphic association using Searchlogic
...ry.timesheet_enterable_task_type_project_id_equals(217).entry_type_equals("project") NoMethodError: undefined method `timesheet_enterable_task_type_project_id_equals'' for #<Class: 0x36bd660> from /Users/chino/Documents/git/isf001/vendor/plugins/searchlogic/lib/ searchlogic/named_scopes/conditions.rb:88:in `method_missing'' from /Users/chino/Documents/git/isf001/vendor/plugins/searchlogic/lib/ searchlogic/named_scopes/association_conditions.rb:19:in `method_missing'' from /Users/chino/Documents/git/isf001/vendor/plugins/searchlogic/lib/ searchlogic/named_scopes...
2008 Jun 03
1
Custom counter cache
class Category has_many :tracks end class Track belongs_to :category, :counter_cache => true named_scope :converted, :conditions => {:converted => true} named_scope :active, :conditions => {:active => true} end I want to make custom counters for scoped associations, e.g: category.converted_tracks_count category.active_tracks_count And when `track` changes its converted, active, and c...
2009 Nov 01
1
please help - complicated polymorphic association
...ble, :polymorphic => true end The tricky part is that users already own appointments, so I can''t create a simple users.appointments association. I can find users by calling appointment.subscribers, but I need help getting the reverse to work (users.subscribers.appointments) I can use named_scope to only grab appointment subscriber objects, but how can I make it automatically link to the appointments, not the subscriber objects?
2008 May 22
14
Specifying certain tables NOT to be cleared each example?
...eally don''t want to have to specify 15-20 fixtures on every example. Yes, I could mock/stub all the values, except that I use many of these values at class definition time, which means that errors are thrown before I can even mock/stub. For instance, I have a statement like this. named_scope :open, :conditions => ["lead_status_id IN (?)", %w{New Incubating Client UAG}.collect{|x| LeadStatus[x].id}] Which loads the named_scope using the string version of the enumeration for clarity''s sake. It works great, except for testing. Does anybody see anyway around th...
2010 Jun 24
3
DRY a named scope
Is there a way to DRY this up a bit? named_scope :has_valid_sysoid, lambda{|sysoid| (sysoid.nil?) ? {:conditions => ["nodesysoid IS NOT NULL AND nodelabel LIKE ''%-to-%''"], :include => [:ipinterface, :alarm]} : {:conditions => ["nodesysoid IS NOT NULL AND nodelabel LIKE ''%-to-%'' AND...