Hi,
i am very new to ROR, this is my 2nd day since i solve the problem of database connection. when i started to write some codes, i got stuck. here is the situation and please give me some help.
i have a "posts" table in my database
CREATE TABLE `mapapp`.`posts` ( `id` int(11) NOT NULL auto_increment, `title` varchar(255) default NULL, `body` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
i have an empty "post.rb" in my Models which looks like this: class Post < ActiveRecord::Base end
i wrote an action in my controller which looks like this: def testing @posts = Post for p in @posts render :text => p.id end end
when i run this action on the browser, it gives me this error message: NoMethodError in PlcController#testing undefined method `each' for Post:Class RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/ base.rb:1235:in `method_missing' #{RAILS_ROOT}/app/controllers/plc_controller.rb:40:in `testing' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/ base.rb:1235:in `method_missing' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ base.rb:1095:in `send' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ base.rb:1095:in `perform_action_without_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ filters.rb:632:in `call_filter' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ filters.rb:619:in `perform_action_without_benchmark' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ benchmarking.rb:66:in `perform_action_without_rescue' C:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ benchmarking.rb:66:in `perform_action_without_rescue' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ rescue.rb:83:in `perform_action' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ base.rb:430:in `send' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ base.rb:430:in `process_without_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ filters.rb:624:in `process_without_session_management_support' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ session_management.rb:114:in `process' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ base.rb:330:in `process' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in `dispatch' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb: 113:in `handle_dispatch' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:79:in `service' C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' C:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start' C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' C:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start' C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each' C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start' C:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start' C:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:63:in `dispatch' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/ webrick.rb:59 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:495:in `require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:342:in `new_constants_in' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:495:in `require' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' script/server:3 C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/ base.rb:1235:in `method_missing' #{RAILS_ROOT}/app/controllers/plc_controller.rb:40:in `testing' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ base.rb:1095:in `send' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ base.rb:1095:in `perform_action_without_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ filters.rb:632:in `call_filter' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ filters.rb:619:in `perform_action_without_benchmark' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ benchmarking.rb:66:in `perform_action_without_rescue' C:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ benchmarking.rb:66:in `perform_action_without_rescue' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ rescue.rb:83:in `perform_action' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ base.rb:430:in `send' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ base.rb:430:in `process_without_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ filters.rb:624:in `process_without_session_management_support' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ session_management.rb:114:in `process' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/ base.rb:330:in `process' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in `dispatch' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb: 113:in `handle_dispatch' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:79:in `service' C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' C:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start' C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' C:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start' C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each' C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start' C:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start' C:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:63:in `dispatch' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/ webrick.rb:59 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:495:in `require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:342:in `new_constants_in' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/ dependencies.rb:495:in `require' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' script/server:3
i m very new, so please excuse me if i asked stupid questions.
but thanks for you time looking.