Hi Ruud,
Scaffolding isn''t meant to be used as end, all code, 99.9% of the
time you will have to mod it to your liking.
also....
http://www.ruby-doc.org/core/ -> check out the send method in the
object class
~-----------------------------~
Jamie Quint
jamiequint-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
www.jamiequint.com
M:503.830.4208
On Sep 29, 2006, at 4:53 PM, Ruudcho wrote:
>
> 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
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---