GithubHelp home page GithubHelp logo

couchbase-ruby-model's Introduction

Couchbase Model

This library allows to declare models for couchbase gem.

SUPPORT

If you found an issue, please file it in our JIRA. Also you are always welcome on #libcouchbase channel at freenode.net IRC servers.

Documentation: http://rdoc.info/gems/couchbase-model

Rails integration

To generate config you can use rails generate couchbase:config:

$ rails generate couchbase:config
create  config/couchbase.yml

It will generate this config/couchbase.yml for you:

common: &common
  hostname: localhost
  port: 8091
  username:
  password:
  pool: default

development:
  <<: *common
  bucket: couchbase_tinyurl_development

test:
  <<: *common
  bucket: couchbase_tinyurl_test

# set these environment variables on your production server
production:
  hostname: <%= ENV['COUCHBASE_HOST'] %>
  port: <%= ENV['COUCHBASE_PORT'] %>
  username: <%= ENV['COUCHBASE_USERNAME'] %>
  password: <%= ENV['COUCHBASE_PASSWORD'] %>
  pool: <%= ENV['COUCHBASE_POOL'] %>
  bucket: <%= ENV['COUCHBASE_BUCKET'] %>

Examples

require 'couchbase/model'

class Post < Couchbase::Model
  attribute :title
  attribute :body
  attribute :draft
end

p = Post.new(:id => 'hello-world',
             :title => 'Hello world',
             :draft => true)
p.save
p = Post.find('hello-world')
p.body = "Once upon the times...."
p.save
p.update(:draft => false)
Post.bucket.get('hello-world')  #=> {"title"=>"Hello world", "draft"=>false,
                                #    "body"=>"Once upon the times...."}

You can also let the library generate the unique identifier for you:

p = Post.create(:title => 'How to generate ID',
                :body => 'Open up the editor...')
p.id        #=> "74f43c3116e788d09853226603000809"

There are several algorithms available. By default it use :sequential algorithm, but you can change it to more suitable one for you:

class Post < Couchbase::Model
  attribute :title
  attribute :body
  attribute :draft

  uuid_algorithm :random
end

You can define connection options on per model basis:

class Post < Couchbase::Model
  attribute :title
  attribute :body
  attribute :draft

  connect :port => 80, :bucket => 'blog'
end

Validations

There are all methods from ActiveModel::Validations accessible in context of rails application:

class Comment < Couchbase::Model
  attribute :author, :body

  validates_presence_of :author, :body
end

Views (aka Map/Reduce indexes)

Views are stored in models directory in subdirectory named after the model (to be precious design_document attribute of the model class). Here is an example of directory layout for Link model with three views.

.
└── app
    └── models
        ├── link
        │   ├── total_count
        │   │   ├── map.js
        │   │   └── reduce.js
        │   ├── by_created_at
        │   │   └── map.js
        │   └── by_view_count
        │       └── map.js
        └── link.rb

To generate view you can use yet another generator rails generate couchbase:view DESIGNDOCNAME VIEWNAME. For example how total_count view could be generated:

$ rails generate couchbase:view link total_count

The generated files contains useful info and links about how to write map and reduce functions, you can take a look at them in the templates directory.

In the model class you should declare accessible views:

class Post < Couchbase::Model
  attribute :title
  attribute :body
  attribute :draft
  attribute :view_count
  attribute :created_at, :default => lambda { Time.now }

  view :total_count, :by_created_at, :by_view_count
end

And request them later:

Post.by_created_at(:include_docs => true).each do |post|
  puts post.title
end

Post.by_view_count(:include_docs => true).group_by(&:view_count) do |count, posts|
  p "#{count} -> #{posts.map{|pp| pp.inspect}.join(', ')}"
end

couchbase-ruby-model's People

Contributors

avsej avatar davidjrice avatar jmoses avatar ka8725 avatar mje113 avatar sohaibbhatti avatar stakach avatar t3hpr1m3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

couchbase-ruby-model's Issues

Mysql2::Error: Can't find file error raised

Hello.

I just installed 'couchbase 1.3.3' and 'couchbase-model 0.5.3' gem on my Rails app (3.2.16) today.
When I start my rails app, I see this error below.

/Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query': Mysql2::Error: Can't find file: './mydb/onetable.frm' (errno: 13): SHOW FULL FIELDS FROM `onetable` (ActiveRecord::StatementInvalid)
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `block in execute'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.16/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `execute'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/connection_adapters/mysql2_adapter.rb:213:in `execute'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:259:in `execute_and_free'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:426:in `columns'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/model_schema.rb:229:in `yield'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/model_schema.rb:229:in `default'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/model_schema.rb:229:in `columns'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/model_schema.rb:238:in `columns_hash'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/locking/optimistic.rb:131:in `locking_enabled?'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/relation.rb:170:in `exec_queries'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/relation.rb:160:in `block in to_a'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/explain.rb:41:in `logging_query_plan'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/relation.rb:159:in `to_a'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.16/lib/active_record/relation/finder_methods.rb:159:in `all'
    from /Users/me/Dev/Projects/App/MyRailsApp/app/models/onetable.rb:25:in `<class:ImageQualityType>'
    from /Users/me/Dev/Projects/App/MyRailsApp/app/models/onetable.rb:15:in `<top (required)>'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:469:in `load'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:469:in `block in load_file'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:639:in `new_constants_in'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:468:in `load_file'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:353:in `require_or_load'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:313:in `depend_on'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:225:in `require_dependency'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/couchbase-model-0.5.3/lib/couchbase/railtie.rb:116:in `block (4 levels) in <class:Railtie>'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/couchbase-model-0.5.3/lib/couchbase/railtie.rb:115:in `each'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/couchbase-model-0.5.3/lib/couchbase/railtie.rb:115:in `block (3 levels) in <class:Railtie>'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/couchbase-model-0.5.3/lib/couchbase/railtie.rb:114:in `each'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/couchbase-model-0.5.3/lib/couchbase/railtie.rb:114:in `block (2 levels) in <class:Railtie>'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:429:in `_run__1552831612745726444__prepare__1164779790096791275__callbacks'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:405:in `__run_callback'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:81:in `run_callbacks'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.16/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.16/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.16/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.16/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.16/lib/rails/initializable.rb:30:in `run'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.16/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.16/lib/rails/initializable.rb:54:in `each'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.16/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.16/lib/rails/application.rb:136:in `initialize!'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.16/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/me/Dev/Projects/App/MyRailsApp/config/environment.rb:9:in `<top (required)>'
    from /Users/me/Dev/Projects/App/MyRailsApp/config.ru:3:in `require'
    from /Users/me/Dev/Projects/App/MyRailsApp/config.ru:3:in `block in <main>'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
    from /Users/me/Dev/Projects/App/MyRailsApp/config.ru:in `new'
    from /Users/me/Dev/Projects/App/MyRailsApp/config.ru:in `<main>'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.16/lib/rails/commands/server.rb:46:in `app'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.16/lib/rails/commands/server.rb:70:in `start'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.16/lib/rails/commands.rb:55:in `block in <top (required)>'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.16/lib/rails/commands.rb:50:in `tap'
    from /Users/me/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.16/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'

My Rails app already uses mysql gem with ActiveRecord, but I haven't seen this error before. I just figured out that this error only raised when I use 'couchbase-model' gem.

Does anyone see this error?

Thank you!

Validation doesn't return error message

I would like to get message what field isn't valid. Validation is working but it is always just returning false. I explicitly called errors method and just got the hash of the object with empty message object.

Is there a way that I can get message that describes what field isn't validated?
Maybe you can point me how I can help in fixing this so that we improve validation.

Add MassAssignmentSecurity

Working on this now... should have a pull request by this weekend.

I wanted to get feedback if the following structure was ok for adding Mass Assignment support.

I figured unlike ActiveRecord we need to explicitly state what attributes exist in the model for Couchbase-Model.

If we then wanted to define what attributes are accessible or protected we would follow the expected convention from ActiveModel::MassAssignmentSecurity.

require 'couchbase/model'

class Post < Couchbase::Model
  attribute :title
  attribute :body
  attribute :draft

  attr_accessible :title, :as => admin
  attr_accessible :body, :as => user

end

And to Save if you needed to provide a role you could as part of the options hash

    p = Post.new(
                 :body  => 'filter',
                 :title => 'Hello world',
                 :draft => true)
    p.save(:as=> :admin)

Default Attributes Modified Through Instance Objects

Since Ruby relies heavily on references, directly modifying an attribute for an object using the default value will in some cases modify the default value instead of the instance object. Example:

class Foo < Couchbase::Model
  attribute :bar, :default => ::Hash.new
end

f1 = Foo.new
f1.bar[:test] # nil
f1.bar[:test] = 1

f2 = Foo.new
f2.bar[:test] # 1 - should be nil

Either the attribute method needs to be aware of this "gotcha" or it needs to be well-documented to use procs as a workaround:

class Foo < Couchbase::Model
  attribute :bar, :default => lambda {::Hash.new}
end

f1 = Foo.new
f1.bar[:test] # nil
f1.bar[:test] = 1

f2 = Foo.new
f2.bar[:test] # nil

encapsulation issue with Couchbase::Model ?

when a couchbase model has a mutable attribute you cannot modify that attribute in place without changing it for all other instances of that class:

class Foo < Couchbase::Model
 attribute :foo, default: []
end

f = Foo.new
f.foo # => []
f.foo << "Hi"
f.foo #=> ["Hi"]

g = Foo.new
g.foo # => ["Hi"]
g.foo << "Bye"

f.foo # => ["Hi", "Bye"]

Rails app cannot start, hangs on 'no implicit conversion of String into Integer'

Hello, I run couchbase in docker via a docker-compose file, in parallel with my rails app which is in the same compose file.

I can configure couchbase properly, I can save and recall Objects through the orm so I'm sure there is no problem with network or configuration.

BUT as soon as I declare a view in the model, the app cannot start, and stops on TypeError: no implicit conversion of String into Integer from /usr/local/bundle/gems/couchbase-1.3.15/lib/couchbase/view.rb:39:in []'`

I have this in the error.log of the couchbase container : [ns_server:error,2017-04-25T16:27:57.122Z,[email protected]:<0.11995.0>:menelaus_web:loop:187]Server error during processing: ["web request failed", {path,"/pools"}, {method,'GET'}, {type,error}, {what, {case_clause, {error, <<"dial unix /var/run/sasl2/mux: connect: no such file or directory">>}}}, {trace, [{menelaus_auth,verify_rest_auth,2, [{file,"src/menelaus_auth.erl"}, {line,300}]}, {menelaus_web,perform_action,2, [{file,"src/menelaus_web.erl"}, {line,900}]}, {request_throttler,do_request,3, [{file,"src/request_throttler.erl"}, {line,59}]}, {menelaus_web,loop,2, [{file,"src/menelaus_web.erl"}, {line,165}]}, {mochiweb_http,headers,5, [{file, "/home/couchbase/jenkins/workspace/watson-unix/couchdb/src/mochiweb/mochiweb_http.erl"}, {line,94}]}, {proc_lib,init_p_do_apply,3, [{file,"proc_lib.erl"},{line,239}]}]}]

But really anything calling the make_http_request of the Bucket class gives the same result. Any ideas ?

Passing in stale: false when querying a view times out the query

If you do something like

Avatar.by_user_id(key: '08164b3a13c28f051b4f4fc2ad00108c', stale: false).first 

the query times out.

The following will return a model.

Avatar.by_user_id(key: '08164b3a13c28f051b4f4fc2ad00108c').first  

Gemfile Lock

    couchbase (1.3.9)
      connection_pool (>= 1.0.0, <= 3.0.0)
      multi_json (~> 1.0)
      yaji (~> 0.3, >= 0.3.2)
    couchbase-model (0.5.4)
      activemodel
      couchbase (~> 1.3.3)

Package Versions

ii  couchbase-server                                      2.5.1                                               amd64        Couchbase Server
ii  libcouchbase-dev                                      2.4.1                                               amd64        library for the Couchbase protocol, development files
ii  libcouchbase2-core                                    2.4.1                                               amd64        library for the Couchbase protocol, core files
ii  libcouchbase2-libevent                                2.4.1                                               amd64        library for the Couchbase protocol (libevent backend)

Support ActiveRecord callbacks

Couchrest-model supports the following callbacks:

:before_validation, :after_validation, :after_initialize, :before_create, :around_create, :after_create, :before_destroy, :around_destroy, :after_destroy, :before_save, :around_save, :after_save, :before_update, :around_update, :after_update

However, couchbase-ruby-model doesn't seem to support them all since I am receiving the following error:

undefined method 'before_validation' for User(id):Class (NoMethodError)

Would it be possible to add the missing callbacks?

Generate views at runtime

Couchrest model is easily implemented because it generates any missing views at runtime. It would be really great if this could do the same.

Config unable to connect with remote Couchbase server

Trying to run rails generate model post, throws error

error couchbase [not found]

config/couchbase.yml:

common: &common
   hostname: 192.168.166.101
   port: 8091
   username:
   password:
   pool: default

development:
  <<: *common
  bucket: cbpb_development

test:
  <<: *common
  bucket: cbpb_test

# set these environment variables on your production server
production:
  hostname: <%= ENV['COUCHBASE_HOST'] %>
  port: <%= ENV['COUCHBASE_PORT'] %>
  username: <%= ENV['COUCHBASE_USERNAME'] %>
  password: <%= ENV['COUCHBASE_PASSWORD'] %>
  pool: <%= ENV['COUCHBASE_POOL'] %>
  bucket: <%= ENV['COUCHBASE_BUCKET'] %>

Have been running into similar issues all day (http://www.couchbase.com/forums/thread/beer-sample-rails-remote-database-servers) - can someone explain why the config is not working?

Thanks!

couchbase-ruby-model still maintained?

Is this still maintained or is there any other plan laid out? What is the approach one should follow when it comes to Couchbase and Rails integration?

Rails generator for model

Couchbase-model shouldn't assume all models will inherit from Couchbase::Model - it essentially breaks the active record model generation flow when the couchbase-model gem is present in the gemfile.

Example: My app connects to several datastores including mysql and couchbase so my use case is to have models that inherit from different parent base classes

Conditional validation fails when calling #persisted? on create

I'd like to add a conditional validation that allows me to create a record without a required field, but become required for subsequent savings, for example:

class User < Couchbase::Model
  attribute :name
  attribute :email
  validates_presence_of :email, if: Proc.new{ |u| u.persisted? }
end

The problem I find is that #persisted? works by checking the presence of the @id which is created just before the validations are checked, so the conditional validation always fails if I want to create a record without the email field.

I think the solutions is to call #valid? before creating the id:

    def create(options = {})
      if respond_to?(:valid?) && !valid?
        return false
      end
      @id ||= Couchbase::Model::UUID.generator.next(1, model.thread_storage[:uuid_algorithm])
      .........
   end

Or perhaps a better solution would be to modify #persisted? to check for the presence of @meta['cas'] like this:

  def persisted?
    !!(meta && meta['cas'])
  end

I could create a PR for this, what do you think?

Issue integrating with Sinatra

I'm trying to do a Sinatra API around Couchbase. I was able to connect with a a config file in config/couchbase.yml and a single ruby file no problem.

Now that I'm trying to wrap it in Sinatra, I'm using the same config file, and the same model definition (now in a separate file that's being pulled in)

Now it's telling me it can't find the bucket, which doesn't make sense since I'm able to connect without Sinatra.

I'm not using any local views yet, I'm just testing the writing.

Is there any way to figure out where it's unable to connect?

Controller I'm using to test with:

get '/test' do

    start = Time.now()
    i = 1
    while ( i < 10 ) do
        p = Ad.new(:name => "test")
        p.save
        i += 1
    end
    stop = Time.now()
    time = stop - start
    json :message => "Writes done in " + time.to_s + " milliseconds"

end

Model Declaration:

class Ad < Couchbase::Model
  attribute :name
  attribute :company_id
  attribute :url
  attribute :click_url
  attribute :location
  attribute :dimensions
  attribute :category
  attribute :content_type
  attribute :type, :default => "ad"
end

Config file (config/couchbase.yml)

common: &common
  hostname: localhost
  port: 8091
  username: Administrator
  password: <password>
  pool: default

development:
  <<: *common
  bucket: <bucket>

Stack Trace:

Couchbase::Error::BucketNotFound -  (error=0x19):
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/couchbase-1.3.6/lib/couchbase.rb:63:in `initialize'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/couchbase-1.3.6/lib/couchbase.rb:63:in `new'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/couchbase-1.3.6/lib/couchbase.rb:63:in `connect'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/couchbase-1.3.6/lib/couchbase.rb:138:in `bucket'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/couchbase-model-0.5.3/lib/couchbase/model.rb:752:in `bucket'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/couchbase-model-0.5.3/lib/couchbase/model.rb:524:in `create'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/couchbase-model-0.5.3/lib/couchbase/model.rb:559:in `save'
    /Users/Meatshield/Airvirtise/test/controllers/test.rb:7:in `block in <top (required)>'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:1593:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:1593:in `block in compile!'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:957:in `[]'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:957:in `block (3 levels) in route!'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:976:in `route_eval'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:957:in `block (2 levels) in route!'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:997:in `block in process_route'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:995:in `catch'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:995:in `process_route'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:955:in `block in route!'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:954:in `each'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:954:in `route!'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:1067:in `block in dispatch!'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:1049:in `block in invoke'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:1049:in `catch'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:1049:in `invoke'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:1064:in `dispatch!'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:889:in `block in call!'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:1049:in `block in invoke'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:1049:in `catch'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:1049:in `invoke'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:889:in `call!'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:877:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/rack-protection-1.5.2/lib/rack/protection/xss_header.rb:18:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/rack-protection-1.5.2/lib/rack/protection/path_traversal.rb:16:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/rack-protection-1.5.2/lib/rack/protection/json_csrf.rb:18:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/rack-protection-1.5.2/lib/rack/protection/base.rb:50:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/rack-protection-1.5.2/lib/rack/protection/base.rb:50:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/rack-protection-1.5.2/lib/rack/protection/frame_options.rb:31:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.5.2/lib/rack/logger.rb:15:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.5.2/lib/rack/commonlogger.rb:33:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:217:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:210:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/show_exceptions.rb:21:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:180:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:2004:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:1469:in `block in call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:1778:in `synchronize'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.4/lib/sinatra/base.rb:1469:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/thin-1.6.1/lib/thin/connection.rb:82:in `block in pre_process'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/thin-1.6.1/lib/thin/connection.rb:80:in `catch'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/thin-1.6.1/lib/thin/connection.rb:80:in `pre_process'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `call'
    /Users/Meatshield/.rvm/gems/ruby-2.0.0-p195/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `block in spawn_threadpool'
127.0.0.1 - - [23/Feb/2014 18:34:45] "GET /__sinatra__/500.png HTTP/1.1" 304 - 0.0040

"rails generate couchbase:view DESIGNDOCNAME VIEWNAME" breaks save_design_doc

I obtain:

Couchbase::Error::HTTP: failed to execute HTTP request (key="_design/coupon_code_c", status="400" (Bad Request), error=0x00)
    from /ruby-1.9.3-p327/gems/couchbase-1.2.1/lib/couchbase/bucket.rb:165:in `continue'
    from /ruby-1.9.3-p327/gems/couchbase-1.2.1/lib/couchbase/bucket.rb:165:in `save_design_doc' 

After removing comments around the function in map.js, it's working again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.