Displaying 20 results from an estimated 3000 matches similar to: "Conditional named_scope chaining with params (Need help)"
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''m trying to implement a
2009 Feb 05
1
[rspec] [rails] Specing a form builder
I''m trying to set up and run a new form builder under rails, which lives
under the helpers directory, but isn''t really a helper. (Not a module, so
doesn''t mix in well)
Short of dropping down into a view spec, how do I set up to actually spec
the form builder?
describe RandomFormBuilder do
attr_reader :builder
before do
@object = mock_model(Foo)
@builder =
2009 Oct 06
3
rspec-rails 1.2.9 Released
rspec-rails version 1.2.9 has been released!
* <http://rspec.info>
* <http://rubyforge.org/projects/rspec>
* <http://github.com/dchelimsky/rspec-rails>
* <http://wiki.github.com/dchelimsky/rspec/rails>
* <rspec-devel at rubyforge.org>
Behaviour Driven Development for Ruby on Rails.
Changes:
### Version 1.2.9 / 2009-10-05
* enhancements
* added route_to and
2012 Feb 22
1
Collect users who posted items with ActsasTaggable on Tag in rails 3
I am using Rails 3 and Acts as taggable on in my application.
I am fetching the articles associated with the tag by
Article.tagged_with("tagname")
and
Blog.tagged_with("tagname")
Now i would like to collect all the users from the above i.e.., people
who are all posted articles and blogs with this tag Please suggest me..
--
Posted via http://www.ruby-forum.com/.
--
You
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 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 later in the chain
Given: Product.price.volume.average_discount
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
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
2009 Jan 23
4
getValue() in a Controller problem, help please.
Hello there,
I''m trying to do something like:
render :update do |page|
page[:client_list].replace_html render(:partial => ''client_list'',
:object => @clients_list)
name = page[:name].getValue();
end
but I''m not getting the value, or somehow use $("name").getValue()
inside of the controller.
How can I do that?
tks,
David Sousa
--
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
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
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 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
2006 Apr 01
3
acts_as_taggable, wrong number of arguments
Hello,
When I try:
@tagged_items = Problem.find_tagged_with :all => ''kuba''
or
@tagged_items = Problem.tags_count :limit => 100
I get this error:
ArgumentError in Volume#index
wrong number of arguments (2 for 3)
RAILS_ROOT: script/../config/..
Application Trace | Framework Trace | Full Trace
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
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
2008 Feb 29
7
Moving pagination to the Model
I''m using will_paginate in a Post class method;
[code]def self.list(page)
paginate :per_page => 10,
:page => page,
:include => :user
end[/code]
I can happily use the method on my posts controller index action;
[code]
class PostsController < ApplicationController
def index
@posts = Post.list(params[:page])
respond_to do |format|
2010 Jun 24
0
Using searchlogic with acts_as_taggable_on
Hi,
i have 2 model, Merchant and Items and using acts_as_taggable_on
Merchant has_many Items, and i try to find Merchant with search logic
including the tags
class Merchant < ActiveRecord::Base
acts_as_taggable
has_many :items
end
class Item < ActiveRecord::Base
acts_as_taggable
belongs_to :merchant
end
This works
>> Merchant.tagged_with(''Tag 1'')
but
2007 Jan 27
2
[UPS on Serial vs. USB] USB slow to update, serial instant.
When I disconnect my UPS from the wall, I have to wait 15-30 seconds
before the USB drier 'polls' this information and tells me that the UPS is
on battery power (via knutclient or syslog via nut):
ups@p34 POWER ALERT on Fri Jan 26 12:49:29 EST 2007
With a serial connection, I would get the alerts IMMEDIATELY (0.5-1
seconds) after disconnecting the UPS. My new machine does not have a
2006 Jun 01
4
FW: How to create a new package?
Hi,
I'm a group of functions and I would like to create a package for load in R.
I have created a directory named INE and a directory below that named R, for
the files of R functions. A have created the files DESCRIPTION and INDEX in
the INE directory. The installation from local zip files, in the R 2.3.0,
results but to load the package I get an error like:
'INE' is not a