mbleigh / subdomain-fu

A new plugin approach to attempting to solve the usage of subdomains in linking and routing in Rails projects.
http://rdoc.info/projects/mbleigh/subdomain-fu
Other
586 stars 118 forks source link

map.with_options fails when using :has_many => [ :associated_models ] #5

Closed ekampp closed 5 years ago

ekampp commented 14 years ago

Hi there.

Firstly, I have this case:

map.with_options :conditions => { :subdomain => "admin" } do |admin| admin.resources :characters, :controller => "admin/characters", :only => [ :index, :edit, :update, :destroy ] end

Note that there is no associated has_many relation to the characters. Secondly I have this in my routes also.

map.with_options :conditions => {:subdomain => 'ingame'} do |ingame| ingame.resources :characters, :only => [ :show, :edit, :update ], :controller => "ingame/characters", :has_many => [ :character_aliases ] end

Now, we agree that going to ingame.something.com/characters/1/character_aliases should list the aliases associated with character 1. And that going to admin.something.com/characters/1/character_aliases should return an error, seeing as there is no has_many relation for the admin subdomain?

This, however, is not the case. Going to admin.something.com/characters/1/character_aliases will show the aliases that should require the ingame subdomain.

Is this an error, or is this intentional? If it's intentional, whats the logic behind?

Best regards Emil

rbranson commented 13 years ago

Add this an initializer:

ActionController::Resources::INHERITABLE_OPTIONS << :conditions