DISQUS

A little place of calm: A little place of calm » Blog Archive » CouchDB on Rails (part 5 of ?)

  • benatkin · 1 year ago
    It's interesting to see how RelaxDB builds on CouchDB. Since CouchDB is so simple, there are many ways to use it, and it's nice to have a library like RelaxDB that provides an example of one way to use it. It looks like RelaxDB makes it easier for people who are used to thinking in terms of tables to begin using CouchDB.

    Nice article. I like how you show every step you take, because I can pick up on little unrelated bits of information (like the "-i" option that can be passed to sudo). It feels like I'm watching a screencast, except I can learn at my own pace and headphones aren't required.
  • Chris Anderson · 1 year ago
    It's really helpful to see the contrast between these frameworks. I'm beginning to think about how best to layer an application-model style wrapper on top of CouchRest. It's good to see what's helpful and what gets in the way, or is missing from these other libraries. Keep up the good work, looking forward to what's next!
  • aimee · 1 year ago
    @Ben, thank you for your encouragement.

    @Chris, i think the most important and useful feature would be to make use of CouchDB's dynamic document structure. If you can make a library that doesn't try to apologise for CouchDB's lack of schema, that would be awesome! :) I think the ability to create its own views when it needs them is a very strong feature.
  • Randy · 1 year ago
    If you are having problems running the spec, you might need to update your gems.

    This is the error I was getting:

    undefined method `generate' for "0322b6d0-6270-012b-24ea-0017f2d556c5":String
  • aimee · 1 year ago
    Hi Randy, the specs are working just fine for me with the RelaxDB. Is your CouchDB server running?
  • Bruno · 1 year ago
    Hi Aimee. First of all congratulations on your blog. I'm learning a lot.
    Now I need some help with running the rspec in my project.
    I'm getting the error:
    rake aborted!
    #42000Unknown database 'sysx_development'
    when i run "rake rspec". This is the database that is in my database.yml file and is setted to mysql. I tried to configure the file like this:
    development:
    adapter: couchdb
    database: sysx_development
    host: 127.0.0.1
    port: 5984
    After that, executing rspec asks for a gem called activerecord-couchdb-adapter. But it doesn't exist. Am I going throw the wrong way?
  • aimee · 1 year ago
    Hi Bruno,

    I don't think you can use database.yml together with CouchDB. There is no couchdb adapter that i know of.

    If you're using RelaxDB you could try putting the details into your config/environment.rb:

    RelaxDB.configure(:host => 'localhost', :port => 5984)
    RelaxDB.use_db 'sysx_development'


    I can't remember whether i maybe had to create an empty MySQL database just so that the database.yml didn't cry.
  • Bruno · 1 year ago
    Hi Aimee,
    I configured the app like you sad. But when rails initialize it keeps calling the database.yml. I tried to turn off in enviroment.rb:
    config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
    There's a bug in rails that it doens't work very well. I think I'm missing something here. Do you have your source code anywhere so I can look at it?
    thanks
  • Daniel Tsadok · 11 months ago
    Great writeup! Aimee - I agree, that setting the properties explicitly is a pain.

    I would imagine that creating a view explicitly in CouchDB would let you do a search by title - sort of like creating a stored procedure (but I haven't read parts 6+ yet, so maybe I'm jumping the gun!) Not Rails-y, but it's not designed for Rails...
  • BiLO · 7 months ago
    very helpful . thank you
  • Claes Nygren · 6 months ago
    A few things:
    I think you now have to specify a design_doc in RelaxDB.configure such as:

    RelaxDB.configure :host => "localhost", :port => 5984, :design_doc => "app"

    also you may have to do

    rake db:migrate

    just to create a db/schema.rb, even if you are not using sqlite before you do

    rake spec