I''ve got a table in my schema which doesn''t have an ID column. Here''s the migration - ==== START OF CUT OF MIGRATION =========================class CreateCountries < ActiveRecord::Migration def self.up create_table(:countries, :id => false, :options => '' IN SFPS001'') do |t| # t.column :name, :string t.column :country_code, :string, :null => false, :limit => 2 t.column :country_name, :string, :null => false, :limit => 50 end end def self.down drop_table :countries end end ==== END OF CUT OF MIGRATION =========================== Here''s the model definition - ==== START OF CUT OF MODEL =============================class Country < ActiveRecord::Base set_primary_key :country_code has_many :trip_leg_passengers, :as => :country_passport has_many :airports validates_presence_of :country_code, :country_name validates_uniqueness_of :country_code validates_uniqueness_of :country_name end ==== END OF CUT OF MODEL =============================== Using the formats in the usual RoR book from Prag Progs, I''ve got the list, show and edit functionality working. However the "Add" function is not working giving the following error dump - ==== START OF CUT OF ERROR OUTPUT ======================= NoMethodError in Country#new Showing app/views/country/_form.rhtml where line #5 raised: undefined method `country_code_before_type_cast'' for #<Country:0xb7414228> Extracted source (around line #5): 2: 3: <!--[form:country]--> 4: <p><label for="country_country_code">Country code</label><br/> 5: <%= text_field ''country'', ''country_code'' %></p> 6: 7: <p><label for="country_country_name">Country name</label><br/> 8: <%= text_field ''country'', ''country_name'' %></p> Trace of template inclusion: /app/views/country/new.rhtml RAILS_ROOT: script/../config/.. Application Trace | Framework Trace | Full Trace /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:178 9:in `normal_method_missing'' /usr/lib/ruby/gems/1.8/gems/dr_nic_magic_models-0.7.1/lib/base.rb:46:in `method_missing'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_he lper.rb:340:in `value_before_type_cast'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_he lper.rb:253:in `to_input_field_tag'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_he lper.rb:160:in `text_field'' #{RAILS_ROOT}/app/views/country/_form.rhtml:5:in `_run_rhtml_country__form'' #{RAILS_ROOT}/app/views/country/new.rhtml:4:in `_run_rhtml_country_new'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:178 9:in `normal_method_missing'' /usr/lib/ruby/gems/1.8/gems/dr_nic_magic_models-0.7.1/lib/base.rb:46:in `method_missing'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_he lper.rb:340:in `value_before_type_cast'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_he lper.rb:253:in `to_input_field_tag'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_he lper.rb:160:in `text_field'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in `compile_and_render_template'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in `render_template'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:251:in `render_file'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:266:in `render'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/partials.rb:59: in `render_partial'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmark ing.rb:29:in `benchmark'' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/lib/ruby/1.8/benchmark.rb:307:in `realtime'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmark ing.rb:29:in `benchmark'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/partials.rb:58: in `render_partial'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:278:in `render'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in `compile_and_render_template'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in `render_template'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:251:in `render_file'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:7 26:in `render_file'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:6 48:in `render_with_no_layout'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/layout.rb :245:in `render_without_benchmark'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmark ing.rb:53:in `render'' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmark ing.rb:53:in `render'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:9 42:in `perform_action_without_filters'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.r b:368:in `perform_action_without_benchmark'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmark ing.rb:69:in `perform_action_without_rescue'' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmark ing.rb:69:in `perform_action_without_rescue'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb :82:in `perform_action'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:4 08:in `process_without_filters'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.r b:377:in `process_without_session_management_support'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_m anagement.rb:117:in `process'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in `handle_dispatch'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in `service'' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'' /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'' /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'' /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in `dispatch'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc ies.rb:147:in `require'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenci es.rb:147:in `require'' script/server:3 /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:178 9:in `normal_method_missing'' /usr/lib/ruby/gems/1.8/gems/dr_nic_magic_models-0.7.1/lib/base.rb:46:in `method_missing'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_he lper.rb:340:in `value_before_type_cast'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_he lper.rb:253:in `to_input_field_tag'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/form_he lper.rb:160:in `text_field'' #{RAILS_ROOT}/app/views/country/_form.rhtml:5:in `_run_rhtml_country__form'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in `compile_and_render_template'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in `render_template'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:251:in `render_file'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:266:in `render'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/partials.rb:59: in `render_partial'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmark ing.rb:29:in `benchmark'' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/lib/ruby/1.8/benchmark.rb:307:in `realtime'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmark ing.rb:29:in `benchmark'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/partials.rb:58: in `render_partial'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:278:in `render'' #{RAILS_ROOT}/app/views/country/new.rhtml:4:in `_run_rhtml_country_new'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in `compile_and_render_template'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in `render_template'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:251:in `render_file'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:7 26:in `render_file'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:6 48:in `render_with_no_layout'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/layout.rb :245:in `render_without_benchmark'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmark ing.rb:53:in `render'' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmark ing.rb:53:in `render'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:9 42:in `perform_action_without_filters'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.r b:368:in `perform_action_without_benchmark'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmark ing.rb:69:in `perform_action_without_rescue'' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmark ing.rb:69:in `perform_action_without_rescue'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb :82:in `perform_action'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:4 08:in `process_without_filters'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.r b:377:in `process_without_session_management_support'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_m anagement.rb:117:in `process'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in `handle_dispatch'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in `service'' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'' /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'' /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'' /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in `dispatch'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc ies.rb:147:in `require'' /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30 /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenci es.rb:147:in `require'' script/server:3 Request Parameters: None Show session dump --- :user_id: 100 flash: !map:ActionController::Flash::FlashHash {} :original_uri: / Response Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} ==== END OF CUT OF ERROR OUTPUT ========================================== I am assuming I have to change something because the primary key is COUNTRY_CODE and there isn''t an ID column. But I can''t work out what. Any help appreciated. Phil --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---