Frederick C. wrote:
On 15 Apr 2008, at 15:56, James B. wrote:
Fred
If I use the singular fors for entity and site in the belongs_to,
which
is what I did initially, then I get this error in entities/index at
line
64:
Association named ‘sites’ was not found; perhaps you misspelled it?
That means that something is still using the association names sites
(eg an :include => :sites). Track it down.
Fred
I grep’ed my entire project and found only these references to sites:
$ find ./ -print | xargs grep sites | grep -v ‘.svn’ | grep -v ‘vendor’
This stuff is just test fixtures and migrations. As far as I am aware
none of this should have any effect on running code:
./test/fixtures/sites.yml:# Table name: sites
./db/migrate/022_create_sites.rb: create_table :sites do |t|
./db/migrate/022_create_sites.rb: add_index :sites,
[:site_country_code, :site_postal_code],
./db/migrate/022_create_sites.rb: :name =>
:idxR_sites_country_postal_codes,
./db/migrate/022_create_sites.rb: remove_index :sites, :name =>
:idxR_sites_country_postal_codes
./db/migrate/022_create_sites.rb: drop_table :sites
Binary file ./db/development.sqlite3 matches
./db/schema.rb: create_table “sites”, :force => true do |t|
./db/schema.rb: add_index “sites”, [“site_country_code”,
“site_postal_code”], :name => “idxR_sites_country_postal_codes”
Binary file ./app/models/.site.rb.swp matches
This is the stuff of interest:
./app/models/entity.rb: :include =>
:sites
./app/models/entity.rb: has_many :sites, :through =>
:locations
./app/models/site.rb:# Table name: sites
Is the :include => :sites in entity.rb the problem? If so then why?
./app/controllers/sites_controller.rb: # GET /sites
./app/controllers/sites_controller.rb: # GET /sites.xml
./app/controllers/sites_controller.rb: @sites = Site.find(:all)
./app/controllers/sites_controller.rb: format.xml { render :xml =>
@sites }
./app/controllers/sites_controller.rb: # GET /sites/1
./app/controllers/sites_controller.rb: # GET /sites/1.xml
./app/controllers/sites_controller.rb: # GET /sites/new
./app/controllers/sites_controller.rb: # GET /sites/new.xml
./app/controllers/sites_controller.rb: # GET /sites/1/edit
./app/controllers/sites_controller.rb: # POST /sites
./app/controllers/sites_controller.rb: # POST /sites.xml
./app/controllers/sites_controller.rb: # PUT /sites/1
./app/controllers/sites_controller.rb: # PUT /sites/1.xml
./app/controllers/sites_controller.rb: # DELETE /sites/1
./app/controllers/sites_controller.rb: # DELETE /sites/1.xml
./app/controllers/sites_controller.rb: format.html {
redirect_to(sites_url) }
./app/views/sites/edit.html.erb:<%= link_to ‘Back’, sites_path %>
./app/views/sites/index.html.erb:
Listing sites
./app/views/sites/index.html.erb:<% for site in
@sites %>
./app/views/sites/new.html.erb:<%= link_to ‘Back’, sites_path %>
./app/views/sites/show.html.erb:<%= link_to ‘Back’, sites_path %>
./app/views/locations/new.html.erb: <%= render :partial =>
‘sites/site_detail’,
./config/routes.rb: map.resources :sites do |site|
You assistance has been greatly appreciated.