I almost suspect that I can't do this because it hasn't yet worked for
me...
My Salon model...
this works...
named_scope :states,
:group => 'state',
:select => 'state'
doesn't seem to work (at least not in script/console)
named_scope :salon_cities_by_state,
:conditions => {:state => @state},
:group => 'city',
:select => 'city'
in script/console...
@state = "AZ"
=> "AZ"
Salon.states
=> [#<Salon state: "AZ">, #<Salon state: "CA">, #<Salon state: "CT">,
#<Salon state: "NV">, #<Salon state: "NY">, #<Salon state: "TX">]
Salon.salon_cities_by_state
=> []
But if I manually execute the 'named_scope' in script/console, it
works...
Salon.find(:all, :conditions => {:state => @state}, :group =>
'city', :select => 'city')
=> [#<Salon city: "Chandler">, #<Salon city: "Flagstaff">, #<Salon city:
"Glendale">, #<Salon city: "Mesa">, #<Salon city: "Phoenix">, #<Salon
city: "Prescott">, #<Salon city: "Scottsdale">, #<Salon city: "Sun
City">, #<Salon city: "Tempe">, #<Salon city: "Tucson">]
Is there a way I can pass a param to a named_scope so I can build my
dynamically array in any view for any model?
Craig
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.