Welcome Guest | Login

db access error... but it works in console

Hi.

I have a db access error. This code used to work on my last server, and seems to work in the console:

_______________________________________
Here's the console interaction, so I know my Greeting & FreeGreeting records are being accessed OK:


Loading production environment (Rails 2.0.2)
>> Greeting.class
=> Class
>> g = Greeting.find(10)
=> #<Greeting id: 10, name: "Beatles Trivia 4", user_id: 3, description: "Beatles Trivia 4", permission_id: 2, listens: 2024, last_updated: "2007-09-22 17:48:41", date_added: "2007-09-22 17:48:41", size: 217342, content_type: "audio/x-wav", filename: "beatles4.wav", exports: 1508>
>> FreeGreeting.class
=> Class
>> f = FreeGreeting.find(:all)
=> [#<FreeGreeting id: 1, greeting_id: 10>, #<FreeGreeting id: 2, greeting_id: 11>, #<FreeGreeting id: 3, greeting_id: 12>, #<FreeGreeting id: 4, greeting_id: 13>, #<FreeGreeting id: 5, greeting_id: 16>]
>>
________________________________________

here's the start of greeting.rb

[.../app/models]# more greeting.rb
class Greeting < ActiveRecord::Base
 belongs_to :free_greeting
 belongs_to :user
 belongs_to :permission
 has_and_belongs_to_many :tags

here's freegreeting.rb

[.../app/models]# more free_greeting.rb
class FreeGreeting < ActiveRecord::Base
 belongs_to :greeting
end

__________________________________________

here's the code used to access the records:

  fg = FreeGreeting.find(:all)
   @free_greetings = Array.new()
line 17:    fg.each do |f|
line 18:      @free_greetings << f.greeting
   end

___________________________________________
Here's the production.log dump:

Processing GreetingsController#index (for 24.37.130.16 at 2008-04-20 06:39:27) [GET]
 Session ID: BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%0ASGFzaHsABjoKQHVzZWR7AA%3D%3D--bbbd8cb08ed45bae31c490b687b7870ca8a02a14
 Parameters: {"action"=>"index", "controller"=>"greetings"}
 FreeGreeting Load (0.000067)   SELECT * FROM `free_greetings`


LoadError (Expected /home/tedhill/voicealmighty/app/models/greeting.rb to define Greeting):
   /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:249:in `load_missing_constant'
   /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing'
   /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:465:in `const_missing'
   /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1748:in `compute_type'
   /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/reflection.rb:125:in `send'
   /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/reflection.rb:125:in `klass'
   /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/belongs_to_association.rb:44:in `find_target'
   /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/association_proxy.rb:133:in `load_target'
   /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/association_proxy.rb:55:in `reload'
   /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations.rb:992:in `greeting'
   /app/controllers/greetings_controller.rb:18:in `index'
   /app/controllers/greetings_controller.rb:17:in `each'
   /app/controllers/greetings_controller.rb:17:in `index'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in `send'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:1158:in `perform_action_without_filters'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:697:in `call_filters'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:689:in `perform_action_without_benchmark'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
   /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/rescue.rb:199:in `perform_action_without_caching'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:678:in `perform_action'
   /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
   /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/query_cache.rb:8:in `cache'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:677:in `perform_action'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `send'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:524:in `process_without_filters'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/filters.rb:685:in `process_without_session_management_support'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/session_management.rb:123:in `process'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:388:in `process'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:171:in `handle_request'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
   /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
   /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:101:in `process_request'
   /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:149:in `with_signal_handler'
   /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:99:in `process_request'
   /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:77:in `process_each_request'
   /usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:612:in `each_cgi'
   /usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each'
   /usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each_cgi'
   /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:76:in `process_each_request'
   /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:50:in `process!'
   /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/fcgi_handler.rb:24:in `process!'
   dispatch.fcgi:24

_____________________________________

Any thoughts?

Tedzo.

2008-04-20 07:38 AM

Old guy still coding
Hi Tedzo,

Your site is now working. Previously your site was running in FCGI and I have setup the mongrel proxy, now your site is running in  mongrel. In the app/controllers/greetings_controller.rb there was a syntax error.
===============================================================  
@com_greetings_pages, @com_greetings = paginate (:greetings, {:conditions => ["permission_id = ?", perm.id], :per_page => 10})
===============================================================
One space was missing near "paginate" key word, I have also added that space.

2008-04-20 03:26 PM

Thanks :)

2008-04-20 08:58 PM

Old guy still coding

Hello Guest! In order to post you must be an active client with us, please log in or sign up.