I have two tables
CREATE TABLE continents ( id int(11) NOT NULL auto_increment, name varchar(255) NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE countries ( id int(11) NOT NULL auto_increment, name varchar(255) NOT NULL, continent_id int(11) NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I generate scaffolds for country and for continent
I modify the models and add belongs_to and has_one:
class Continent < ActiveRecord::Base belongs_to :country end
class Country < ActiveRecord::Base has_one :continent end
The code that is generated to show a country record is
<% for column in Country.content_columns %> <p> <b><%= column.human_name %>:</b> <%=h @country.send(column.name) %> </p> <% end %>
<%= link_to 'Edit', :action => 'edit', :id => @country %> | <%= link_to 'Back', :action => 'list' %>
This latter code does NOT display the field continent_id (or continent.name as I would like)
Do I need to rewrite the code so that every individual field that needs to be displayed is generated separately. and for teh foreign keys I generate appropriate code or can the loop for column in be modified?
I also can't find the documentation for the send method in @country.send(column.name). Can someone give me a hint?
Thanks,
Ruud