couchrest / couchrest_model

Doing the simple stuff so you don't have to
Apache License 2.0
304 stars 116 forks source link

Not working "out of the box" with Rails 4 #182

Closed ajcrites closed 11 years ago

ajcrites commented 11 years ago

The documentation claims that Couchrest Model will

work out the box with no configuration as long as your CouchDB instance is running on the default port (5984) on localhost.

I've confirmed that CouchDB is running on port 5984 on localhost.

I performed the following steps:

rails new foo
cd foo
# update Gemfile to remove `gem 'sqlite3'`
# update Gemfile to add `gem 'couchrest_model'`
bundle install # successful
rails s

When I visit localhost:3000 I get the error:

Specified 'sqlite3' for database adapter, but the gem is not loaded. Add gem 'sqlite3' to your Gemfile.

This seems to imply that additional configuration is needed to either select a CouchDB database adapter or forego using an adapter.

Adding config/couchdb.yml, even via rails g couchrest_model:config results in the same issue.

samlown commented 11 years ago

Andrew, the part of the documentation you quote, is referring to the fact that you do not need to configure CouchRest Model to be able to start using it. The assumption made here is that you already have a working rails configuration before adding gem couchrest_model to your Gemfile.

Sqlite3 is required by ActiveRecord, which is completely independent from CouchRest Model. In fact, there may indeed be many scenarios where it is useful to have both ActiveRecord and CouchRest Model available in the same project.

If you no longer want to use ActiveRecord in your project, I'd recommend removing it from your application configuration in config/application.rb. The top part should look something like:

# We don't need active record, so load everything but:
# require 'rails/all'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'rails/test_unit/railtie'

After this, any references to config.active_record in your environment will also need to be removed.

There is also a great answer on StackOverflow for getting around this: http://stackoverflow.com/questions/19078044/disable-activerecord-for-rails-4

Hope that helps.

ajcrites commented 11 years ago

@samlown Your explanation and the SO question made a lot of sense and helped me understand this issue. It may be appropriate to update the documentation for those less experienced with Rails (like me), but maybe that would be overkill.