Hi, I'm a noob trying to figure out the best way to limit queries by a
particular condition that is dependent on the subdomain of the site.
I have a table "places" with a field called "subdomain". Say I have
another table that belongs to places called "knights" (contains
"place_id"). Like so:
`places` table - Place.id, Place.subdomain
`knights` table - Knight.id, Knight.place_id
On the site, "heredia.knightsofni.es", I only want to show the
knights who live in Heredia wherever knights are shown.
My questions are these:
1. What is the best way to set the "active" place globally? Right now
I am setting an instance variable @active_place in
application_controller.rb like so: @active_place = Place.find
(:first, :conditions => ['places = ?', subdomain]). Is this OK, or is
there a better way so that the @active_place data is more globally
available?
2. How can I constrain by place while staying RESTful? Right now I'm
putting if/then statements in my controller methods like so: if
@active_place { @knights = Knight.by_place } else { @knights =
Knight.all }
Thanks for the help,
Ni!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---