From: Paul Thomas Date: 2005-10-04T02:36:47+09:00 Subject: Re: Selecting From A Different Table James Edward Gray II wrote: > On Oct 3, 2005, at 11:31 AM, Paul Thomas wrote: > > > How do I select records from a table that has a different name than my > > controller? > > > > My example is as follows > > > > in locations_controller.rb > > > > class LocationsController < ApplicationController > > > > def new > > @location = Location.new > > @regions = #Needs to do a find(:all) to populate from regions table > > end > > I believe you are looking for: > > @regions = Region.find(:all) > > Assuming I guess your model name correctly. Just remember that find > () is just a method call on some model. > > Hope that helps. > > James Edward Gray II Thanks for the prompt reply. When I call @regions = Region.find(:all) the @regions is empty. Region is my model name as well. Here are my models that are of importance to this. class Region < ActiveRecord::Base has_one :location end class Location < ActiveRecord::Base belongs_to :region end And from the controller def new @location = Location.new @regions = Region.find(:all) # @regions is still empty end And lastly, from the view (_form.rhtml -- used in edit.rhtml and new.rhtml) <% collection_select("location", "region_id", @regions, "id", "name") %>