Config file in Ruby on Rails

There are a bunch of config files in a Ruby on Rails app. The most popular ist the “database.yml” config file. This is for configuring the database connection in 3 different environments. Assume you want to have your config file, in the same style as the database.yml file. Where you can configure some program logicContinue reading “Config file in Ruby on Rails”

Multiple Heroku Accounts on one machine

To have multiple accounts on Heroku is no fun. Specially not if you are a developer and you have to push multiple apps into multiple heroku accounts. The problem is that the heroku toolbelt authentification is based on ssh certificates. If you create your very first heroku app on your machine, heroku will take yourContinue reading “Multiple Heroku Accounts on one machine”

Rails 3.X – “You are being redirected” – “406 Not Acceptable”

I used “redirect_to” in a controller to redirect the user to a different page. And I always got a: “You are being redirected” In the Browser. And a “406 Not Acceptable” in the console. I googled the whole day for this issue. In the end I found out that the problem was a new actionContinue reading “Rails 3.X – “You are being redirected” – “406 Not Acceptable””

MongoID Lessons Learned

I am using MongoID to access MongoDB from a Ruby on Rails application. It is a good library. But there are some things I found out during the project, I want to share here. Nothing bad. Just some behaviors should now about. Case Insensitive Search There are different ways to write queries with MongoID. One pretty coolContinue reading “MongoID Lessons Learned”

Cron Jobs on Heroku

Heroku is an App Engine for Ruby on Rails … and other Languages and Frameworks. Heroku is running your application and you don’t have to care about hardware or IT-Infrastructure. It is one abstraction layer above the Amazon Cloud EC2. First of all, there are no cron jobs on Heroku. Because it is an AppContinue reading “Cron Jobs on Heroku”

Postmark InvalidMessageError

If you get this ERROR her in a Ruby on Rails app: Postmark::InvalidMessageError: Provide either email TextBody or HtmlBody or both That usually means just that you have a misspelling somewhere in your code. Rails is working with a lot of conventions. In my case a directory was miss spelled. After I fixed the spellingContinue reading “Postmark InvalidMessageError”

Handling Routing ERROR in Rails 3.2

Routing Errors are caught if somebody is calling a path on your app which is not existing. This how I handled it. I just added this line to the end of the routes.rb match ‘*path’, :to => ‘page#routing_error’ It is important that this is on the bottom of the routes.rb. That just means, if noContinue reading “Handling Routing ERROR in Rails 3.2”

Failed to connecto to primary node

If you try to connect to MongoDB Replica Set via MognoID and you get this error message here: /opt/local/lib/ruby1.9/gems/1.9.1/gems/mongo-1.5.2/lib/mongo/repl_set_connection.rb:165:inconnect’: Failed to connect to primary node. (Mongo::ConnectionFailure) from /opt/local/lib/ruby1.9/gems/1.9.1/gems/mongo-1.5.2/lib/mongo/repl_set_connection.rb:500:insetup’ from /opt/local/lib/ruby1.9/gems/1.9.1/gems/mongo-1.5.2/lib/mongo/repl_set_connection.rb:144:in initialize’ from /opt/local/lib/ruby1.9/gems/1.9.1/gems/mongoid-2.3.4/lib/mongoid/config/replset_database.rb:24:innew’ from /opt/local/lib/ruby1.9/gems/1.9.1/gems/mongoid-2.3.4/lib/mongoid/config/replset_database.rb:24:in configure’ from /opt/local/lib/ruby1.9/gems/1.9.1/gems/mongoid-2.3.4/lib/mongoid/config.rb:316:inconfigure_databases’ from /opt/local/lib/ruby1.9/gems/1.9.1/gems/mongoid-2.3.4/lib/mongoid/config.rb:119:in from_hash’ from /opt/local/lib/ruby1.9/gems/1.9.1/gems/mongoid-2.3.4/lib/mongoid/config.rb:136:inload!’ from /opt/local/lib/ruby1.9/gems/1.9.1/gems/mongoid-2.3.4/lib/mongoid.rb:147:in load!’ from /Users/reiz/workspace/versioneye/versioneye/config/application.rb:33:inclass:Application’ from /Users/reiz/workspace/versioneye/versioneye/config/application.rb:18:in <module:Versioneye>’ from /Users/reiz/workspace/versioneye/versioneye/config/application.rb:17:in’ from /opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:52:in require’ from /opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:52:inblock in ‘ fromContinue reading “Failed to connecto to primary node”

Rails + MongoDB ReplicaSet Configuration

This article shows how to configure a Ruby on Rails app for a MongoDB ReplicaSet. How to set up a MongoDB ReplicaSet I described here: MongoDB ReplicaSet Tutorial. And how to configure Rails to work together with MongoDB is described here: Rails + MongoDB Quickstart Tutorial. If you want to connect to a ReplicaSet youContinue reading “Rails + MongoDB ReplicaSet Configuration”

Rails + MongoDB Tutorial. Quickstart.

This is a Quickstart Tutorial for Rails + MongoDB. Ruby on Rails and MongoDB, a document based database, is a pretty good fit. It is very easy to integrate MongoDB with Rails. If you want to know how to install MongoDB, check out this article here: Installing MongoDB on Mac OS X Lion. Or thisContinue reading “Rails + MongoDB Tutorial. Quickstart.”

Running Unicorn as a Service on Debian Linux

Unicorn is a very fast app server for Ruby on Rails. You just have to go to the APP_ROOT and type in “unicorn_rails”. And your app is running. The problem with that is, if your server reboots your app is down. And you have to start it again by hand. That is not so cool!Continue reading “Running Unicorn as a Service on Debian Linux”

Installing Ruby 1.9.X on Debian Linux

It is pretty easy to install Ruby on Debian. Just execute this as root: apt-get install ruby1.9.1 That’s it! Depending on that GEMs you want to install you should install this here, too. apt-get install make bcrypt libxml-ruby1.9.1 libxml2-dev libxslt-dev libpq-dev g++ Your GEMs are at “/var/lib/gem/1.9.1/”. You should add this here your path: /var/lib/gem/1.9.1/bin That’s it.

Integration Tests with RSpec

RSpec is a Test Framework for Ruby! And RSpec is just awesome! It is the best Test Framework I know. Add this 2 lines to your Gemfile to the test group and the development group. gem ‘rspec-rails’, ‘2.8.0’ gem ‘webrat’, ‘0.7.3’ Webrat is a browser simulator. With RSpec and Webrat you can write integration tests and test the UI ofContinue reading “Integration Tests with RSpec”

RSpeck before after

RSpec is a Test Framework for Ruby! And RSpec is just awesome! It is the best Test Framework I know. Add this 2 lines to your Gemfile to the test group and the development group. gem ‘rspec-rails’, ‘2.8.0’ gem ‘webrat’, ‘0.7.3’ Webrat is a browser simulator. With RSpec and Webrat you can write integration tests and test the UI ofContinue reading “RSpeck before after”