I am working on an app that has the following setup.

Districts
  District Profiles
    Days_Months

Building
  Building Profiles
  Building Locations


I have the resources nested like this

------------------------------------------
  resources :buildings do
    resources :bprofiles, :shallow => true
    resources :blocations, :shallow => true
  end

  resources :districts do
    resources :dprofiles, :shallow => true
  end
  resources :dprofiles do
    resources :days_months, :shallow => true
  end
  resources :dprofiles, :only => [:index]
  resources :bprofiles, :only => [:index]
  resources :blocations, :only => [:index]
------------------------------------------

When I edit District Profiles, it works fine with an edit or new record
When I edit Buildings Profiles, it works fine with a new profile or if I
edit or create a new location, however fails with an error if I edit a
building profile.

Error comes back as

------------------------------------------
undefined method `building_bprofile_path' for
#<#<Class:0x00000005e7f3d8>:0x007ff6defb8f60>
Extracted source (around line #1):

<%= form_for [@building, @bprofile] do |f| %>
    <% if @bprofile.errors.any? %>
------------------------------------------

Routes do not show that path however locations work and they have the
exact same paths..  The only difference I can see is that Building
Profile is joined with District Profile with a dprofile_id.

------------------------------------------
     building_blocations GET
/buildings/:building_id/blocations(.:format)      blocations#index
                         POST
/buildings/:building_id/blocations(.:format)      blocations#create
  new_building_blocation GET
/buildings/:building_id/blocations/new(.:format)  blocations#new
          edit_blocation GET      /blocations/:id/edit(.:format)
blocations#edit
               blocation GET      /blocations/:id(.:format)
blocations#show
                         PATCH    /blocations/:id(.:format)
blocations#update
                         PUT      /blocations/:id(.:format)
blocations#update
                         DELETE   /blocations/:id(.:format)
blocations#destroy
      building_bprofiles GET
/buildings/:building_id/bprofiles(.:format)       bprofiles#index
                         POST
/buildings/:building_id/bprofiles(.:format)       bprofiles#create
   new_building_bprofile GET
/buildings/:building_id/bprofiles/new(.:format)   bprofiles#new
           edit_bprofile GET      /bprofiles/:id/edit(.:format)
bprofiles#edit
                bprofile GET      /bprofiles/:id(.:format)
bprofiles#show
                         PATCH    /bprofiles/:id(.:format)
bprofiles#update
                         PUT      /bprofiles/:id(.:format)
bprofiles#update
                         DELETE   /bprofiles/:id(.:format)
bprofiles#destroy
               buildings GET      /buildings(.:format)
buildings#index
                         POST     /buildings(.:format)
buildings#create
            new_building GET      /buildings/new(.:format)
buildings#new
           edit_building GET      /buildings/:id/edit(.:format)
buildings#edit
                building GET      /buildings/:id(.:format)
buildings#show
                         PATCH    /buildings/:id(.:format)
buildings#update
                         PUT      /buildings/:id(.:format)
buildings#update
                         DELETE   /buildings/:id(.:format)
buildings#destroy
------------------------------------------

Models are


------------------------------------------
class Building < ActiveRecord::Base
  belongs_to :district
  has_many :blocations
  has_many :bprofiles

class Bprofile < ActiveRecord::Base
  belongs_to :building
  belongs_to :dprofile

class Blocation < ActiveRecord::Base
  belongs_to :building

class District < ActiveRecord::Base
  has_many :buildings
  has_many :dprofiles

class Dprofile < ActiveRecord::Base
  belongs_to :district
  has_many :days_months, -> {order('month_number')}
  has_many :bprofiles

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/abc11ded145b54d248c9dfb5692ce261%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to