henrypoydar / couchrest-rails Goto Github PK
View Code? Open in Web Editor NEWA Rails plugin for connecting to and working with CouchDB via CouchRest
License: MIT License
A Rails plugin for connecting to and working with CouchDB via CouchRest
License: MIT License
Dears i got that Warning while creating the database.
while i have a model using CouchRestRails::Document
class Post < CouchRestRails::Document
use_database :couchtry
property :title
property :body
timestamps!
view_by :title
validates_presence_of :title
end
please advise,
Thanks.
First of all, nice work! I was frustrated with BasicModel and decided to write something better, and then saw you had already done it.
One problem: I get the error above, pretty much no matter what I try to do.
See below for details.
ALso get this when trying to run a unit test.
linux-3:mma uhgall$ rake couchdb:create --trace
(in /Users/uhgall/code/mma)
** Invoke couchdb:create (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant CouchRestRails::Document::COUCHDB_SERVER
/Users/uhgall/code/mma/vendor/rails/activesupport/lib/active_support/dependencies.rb:105:in const_missing' /Users/uhgall/code/mma/vendor/plugins/couchrest-rails/lib/couch_rest_rails/document.rb:3 /Users/uhgall/code/mma/vendor/rails/activesupport/lib/active_support/dependencies.rb:380:in
load_without_new_constant_marking'
/Users/uhgall/code/mma/vendor/rails/activesupport/lib/active_support/dependencies.rb:380:in load_file' /Users/uhgall/code/mma/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in
new_constants_in'
/Users/uhgall/code/mma/vendor/rails/activesupport/lib/active_support/dependencies.rb:379:in load_file' /Users/uhgall/code/mma/vendor/rails/activesupport/lib/active_support/dependencies.rb:259:in
require_or_load'
/Users/uhgall/code/mma/vendor/rails/activesupport/lib/active_support/dependencies.rb:425:in load_missing_constant' /Users/uhgall/code/mma/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in
const_missing'
/Users/uhgall/code/mma/vendor/plugins/basic_model/lib/basic_model.rb:34
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in
require'
I had to comment out the following line in the plugin:
http://github.com/hpoydar/couchrest-rails/blob/master/init.rb#L2
The inclusion of the spec/rails/matchers caused my apps tests to fail badly in a very non-obvious way (required a session with git bisect to resolve the root cause).
I am not sure why is this seemingly test related code is being included in the normal runtime anyway? Shouldn't this only be included when running the plugin tests? There should be no assumptions about rspec being present or in use for apps that pull this plugin in.
Thanks.
The plugin has a hard coded dependency on the 'couchrest' gem in the plugin init:
http://github.com/hpoydar/couchrest-rails/blob/master/init.rb
This is problematic for those of us using one of the many seemingly official forks of couchrest in our app (e.g. jchris-couchrest, mattetti-couchrest, couchrest-couchrest, or just plain couchrest from rubyforge). According to mattettit 'couchrest-couchrest' is the official repo, but building gems from that repo on github seems to be borked.
Instead of hardcoding the specific gem I would instead specify that users need to specify one of these in their environment.rb with the :lib param of 'couchrest'. I am currently using (working ok so far in my very initial usage) the mattetti-couchrest gem in my app. In order to do this I needed to override your init.rb and specify:
config.gem 'mattetti-couchrest', :lib => 'couchrest'
instead of specifying config.gem statements in your plugin, I would try to require 'couchrest', (and the same for the other gems you hardcode) and raise an exception if one is missing. And add to the docs the requirement that the user has provided each of the approprtiate config gem statements in their environment.rb which will be much more flexible for users.
It is a bit strange that CouchRest-rails uses a different validation system than the original CouchRest. Is there any special reason for this?
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require': no such file to load -- rails_generator (LoadError)
The rake tasks only seem to work when passed an argument for the database name to be used, instead of using the config from couchdb.yml.
The way to pass rake arguments are not documented in the couchrest-rails docs, and are tough to find on google (I wasted about an hour or more on figuring out the solution...)
If no args are passed, the rake task runs with no error output, and just generates two blank lines.
As an example if 'foobar' is the name of the database and a db suffix is setup in the couchdb config yml file to add the current env like 'foobar_development':
rake couchdb:create[foobar]
(in /Users/glenn/src/git/underscore-searchlight)
WARNING: there are no CouchRestRails::Document models using foobar
Created database foobar (foobar_development)
Note, also that the warning generated in this example is erroneous. There is a 'foobar' database specified in the model file (but of course, not foobar_development which is handled in the config). The model file was tested from the console with Model.create and it wrote to the expected foobar_development db.
Also note that tasks which don't accept arguments and instead run other tasks (like 'rake couchdb:reset' seem to always fail unless the individual tasks to destroy and create are run with args).
Is there something I am missing here from a config perspective? If not, would it be possible to make the rake tasks use sensible values from the config file? Or if not, can you please add docs to the readme showing which tasks need args, and what args they accept?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.