If you have a project that has no database (it may be hitting a web service), you will want to remove ActiveRecord, ActiveResource, and ActionMailer.
To do this, uncomment the line in environment.rb
19 # Skip frameworks you're not going to use (only works if using vendor/rails).
20 # To use Rails without a database, you must remove the Active Record framework
21 config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
It took me a little while to find why I was getting the mysql error as I didn't have an ActiveRecord model and the stack trace for the error isn't helpful.
Mysql::Error (#28000Access denied for user 'root'@'localhost' (using password: NO)):
/vendor/rails/activerecord/lib/active_record/vendor/mysql.rb:523:in `read'
/vendor/rails/activerecord/lib/active_record/vendor/mysql.rb:153:in `real_connect'
/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:471:in `connect'
/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:165:in `initialize'
/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:88:in `mysql_connection'
/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in `connection='
/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:259:in `retrieve_connection'
/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
/vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
/vendor/rails/actionpack/lib/action_controller/caching.rb:677:in `perform_action'
/vendor/rails/actionpack/lib/action_controller/base.rb:524:in `process_without_filters'
/vendor/rails/actionpack/lib/action_controller/filters.rb:685:in `process_without_session_management_support'
/vendor/rails/actionpack/lib/action_controller/session_management.rb:123:in `process'
/vendor/rails/actionpack/lib/action_controller/base.rb:388:in `process'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:171:in `handle_request'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:115:in `dispatch'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:9:in `dispatch'
/vendor/rails/railties/lib/fcgi_handler.rb:101:in `process_request'
/vendor/rails/railties/lib/fcgi_handler.rb:149:in `with_signal_handler'
/vendor/rails/railties/lib/fcgi_handler.rb:99:in `process_request'
/vendor/rails/railties/lib/fcgi_handler.rb:77:in `process_each_request'
/usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:612:in `each_cgi'
/usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:609:in `each_cgi'
/vendor/rails/railties/lib/fcgi_handler.rb:76:in `process_each_request'
/vendor/rails/railties/lib/fcgi_handler.rb:50:in `process!'
/vendor/rails/railties/lib/fcgi_handler.rb:24:in `process!'
/public/dispatch.fcgi:24
We are developing an application with rails which has no database only xml files.
ReplyDeleteIn this case, if i do the changes suggested by you, will i be able to use other rails freatures such as validations??
Please reply.
Thanks - exactly what i was looking for. And it was there all ready to be uncommented right in my environment.rb file. Got to read these config files :)
ReplyDeletethank you! helped a lot, I never payed attention to that line in particular. =)
ReplyDeletethanks :)
ReplyDeleteThis was exactly what I was looking for.
ReplyDeleteThanks,
-SS
Thought I'd point out an update for Rails 3 - the config has changed.
ReplyDeleteAn update to application.rb will take care of this now. The original place I found the info:
http://stackoverflow.com/questions/2212709/remove-activerecord-in-rails-3-beta