Hi
trying to create a select box in _form.rhtml.
I have a table called organisations that contains fileds, 2 being ‘id’
and ‘name’
these are the fields I need to bring over to the clients _form.rhtml.
whats the best way of going about that??
2 ways i have seen suggested that I cant get to work
-@organisations = Organisation.find_all placed this in def new in
clients_controller.rb
but jsut get an error message when trying to extract the data, not sure
if it would work if there’s no organisations entered either!
-<%
@organisations = Organisation.find(:all, :order => “name”)
collection_select(:Organisation, :name, @organisations, :id, :name)
%>
have also tried putting this in the _form.rhtml, but nothing seems to
happen.
any suggestions??
my models look like this
class Organisation < ActiveRecord::Base
has_one :clients
end
class Client < ActiveRecord::Base
belongs_to :organisation
end