This project is archived and is in readonly mode.

#2181 ✓resolved
Sam Granieri

Default Scope with conditions on create

Reported by Sam Granieri | March 9th, 2009 @ 04:30 PM | in 2.x

I noticed something really weird with default scope.

In one scenario, imagine if you have a model named Car, with a string attribute called color.

By default, you'd want to search on blue or red cars

The class would look like this


class Car
  default_scope :conditions=>{:color=>"Red".."Blue"}
end

If you run this through a controller, you wont be able to create a new car.

Also, I've seen default scope complain if you pass in sql

Is this something that merits a patch?

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Tags

Referenced by

Pages