Displaying 20 results from an estimated 37 matches for "named_scopes".
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
=>
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
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
2010 Mar 09
1
Ruby 1.9 and Searchlogic problem
...y/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/activerecord-2.3.5/lib/active_record/named_scope.rb:97:in
`block (2 levels) in named_scope''
/usr/local/lib/ruby/gems/1.9.1/gems/searchlogic-2.3.11/lib/searchlogic/named_scopes/association_conditions.rb:47:in
`association_condition_options''
/usr/local/lib/ruby/gems/1.9.1/gems/searchlogic-2.3.11/lib/searchlogic/named_scopes/association_conditions.rb:42:in
`create_association_condition''
/usr/local/lib/ruby/gems/1.9.1/gems/searchlogic-2.3.11/lib/searchlogic...
2010 Jan 15
1
Chaining queries in ActiveRecord
...torial way to set up a many-
to-many association. I''m trying to implement a simple search function,
so that I can search for a picture with several given tags.
Now say I want to search for pics that are tagged with "dog" and
"cat". The simplest way to do this is to use named_scopes, for
example:
[code]
class Pic < ActiveRecord::Base
has_many :pic_tags
has_many :tags, :through => :pic_tags
named_scope :dog, options_for_tag(“dog") # options_for_tag(tag) is a
method to generate joined table search conditions, not important
named_scope :cat, options_for_tag(&...
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
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_scope...
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 encountered upgrading our rails app to RSpec
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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To
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 => ''created_at DESC''
else
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_true
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/a...
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,
2009 Nov 01
1
please help - complicated polymorphic association
I am trying to build a shared-appointment system, where users can
subscribe to appointments and be updated whenever changes are made to
them. I have three objects in this system, appointments, users, and
subscribers. Subscribers are a polymorphic object like so:
class Subscriber < ActiveRecord::Base
belongs_to :user
belongs_to :subscribable, :polymorphic => true
end
The tricky part is
2008 May 22
14
Specifying certain tables NOT to be cleared each example?
Is it possible to specify that certain tables not be cleared on each
example.
I''ve inherited a project where a good amount of enumerated data is
stored in the database (US States, statuses, about 15-20 tables worth.
Over all, it''s a reasonable decision that leads to solid production
code (acts_as_enumerated is good). This data is read-only and
relatively static; any
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 nodesysoid = ? ", sysoid], :include =>