Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Problem with Rails 3 and have_scope
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
ericindc  
View profile  
 More options Jan 14 2011, 7:04 pm
From: ericindc <ericmilf...@gmail.com>
Date: Fri, 14 Jan 2011 16:04:26 -0800 (PST)
Local: Fri, Jan 14 2011 7:04 pm
Subject: Problem with Rails 3 and have_scope
I'm not sure how to get have_scope passing.  I'm on Rails 3.0.3 with
using the alpha4 version of remarkable_activerecord.  According to the
docs, what I have should work.

Failure/Error: it { should have_scope(:latest).limit(3) }
       Expected :latest when called on Post scope to SELECT "posts".*
FROM "posts" WHERE (published_at is not null) ORDER BY published_at
desc LIMIT 3, got SELECT "posts".* FROM "posts" WHERE (published_at is
not null) ORDER BY published_at desc LIMIT 3

class Post < ActiveRecord::Base
  has_many :comments

  scope :latest, limit(3)

  default_scope where('published_at is not null').order('published_at
desc')
end

require 'spec_helper'

describe Post do
  it { should have_many(:comments) }

  # Commented out because this breaks with an error about an array
index.  Any ideas?
  #
  #it { should have_default_scope.where('published_at is not
null').order('published_at desc') }
  it { should have_scope(:latest).limit(3) }
end


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ericindc  
View profile  
 More options Jan 14 2011, 7:24 pm
From: ericindc <ericmilf...@gmail.com>
Date: Fri, 14 Jan 2011 16:24:36 -0800 (PST)
Local: Fri, Jan 14 2011 7:24 pm
Subject: Re: Problem with Rails 3 and have_scope
So it looks like have_scope and have_default_scope both don't work.
Is there a solution to this?  Thanks.

On Jan 14, 7:04 pm, ericindc <ericmilf...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christopher Dell  
View profile  
 More options Jan 26 2011, 10:17 am
From: Christopher Dell <ch...@tigrish.com>
Date: Wed, 26 Jan 2011 07:17:18 -0800 (PST)
Local: Wed, Jan 26 2011 10:17 am
Subject: Re: Problem with Rails 3 and have_scope
I'm seeing the same behaviour where the expected SQL is identical to
the received SQL, but the spec fails.

rails (3.0.3)
rspec (2.3.0)
remarkable_activemodel (4.0.0.alpha4)
remarkable_activerecord (4.0.0.alpha4)

On Jan 15, 1:24 am, ericindc <ericmilf...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »