has_secure_password with Rails 4.1

I just started a new project with Rails 4.1 and explored the has_secure_password feature. Really awesome stuff! I hope you are not storing passwords in clear text to your database! You should always store some kind of hashed values instead of clear text passwords. In case somebody steals your database he/she still doesn’t has theContinue reading “has_secure_password with Rails 4.1”

Ruby on Rails + ElasticSearch

This is a tutorial how to use ElasticSearch with Ruby on Rails. ElasticSearch is a distributed RESTful Search Engine build on top of Apache Lucene. Sure! You can use your SQL database for search. But that is usually slow and you will not get very good search results. With ElasticSearch you can deliver a fuzzyContinue reading “Ruby on Rails + ElasticSearch”

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””

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”

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.”

ie.css isn’t precompiled

If you get this Error Message: ActionView::Template::Error (blueprint/ie.css isn’t precompiled) Than that means that your ie.css isn’t precompiled 🙂 No. Seriously. If you get this message, probably you are running on production and your css files are not precompiled. Take a deeper look to the Assets Pipeline in Rails 3.1.X. If your css and js files areContinue reading “ie.css isn’t precompiled”

ActiveRDF + DBPedia + Ruby on Rails

This article show how to use ActiveRDF in Ruby on Rails to write queries for DBPedia. DBPedia is the semantic version of WikiPedia. Basically the whole knowledge in Wikipedia is available in DBPedia over RDF (Resource Definition Framework). There is a query language for RDF called SPARQL. With SPARQL and RDF you can write queriesContinue reading “ActiveRDF + DBPedia + Ruby on Rails”

RAILS_ENV

In Ruby on Rails you have always 3 environments. development test production by default you are working in “development” environment. You can control the environments by setting the “RAILS_ENV” as a system variable in your operating system. Under Linux or Mac OS X you can enforce the environment by adding this variable to you “/etc/bashrc”Continue reading “RAILS_ENV”

Useful Rake commands

Rake is the make for Ruby 🙂 Here is a pretty good introduction to the migrations in Ruby on Rails: http://guides.rubyonrails.org/migrations.html and here some useful commands: rake -T shows all rake targets. To create a schema.rb from the current database exeute rake db:schema:dump to load the schema.rb into the database execute: rake db:schema:load

Using Java in Rails with JRuby

JRuby is a pretty good Java implementation of Ruby. One of the biggest advantages of JRuby is that you can use Java Classes in your Ruby on Rails App. You can import JARs and take advantages of all the Java Libraries and Frameworks. In that way you don’t have to throw away your old JavaContinue reading “Using Java in Rails with JRuby”

Single Sign-On with Facebook & Ruby on Rails

There are over 400 Million people on earth with a Facebook Account. From this point of view it makes absolute sense to offer a Single Sign-On with Facebook. Facebook offers a Login via OAuth 2.0. The Facebook documentation for the Authentication process you can find here: http://developers.facebook.com/docs/authentication/. Before you are using the API from Facebook youContinue reading “Single Sign-On with Facebook & Ruby on Rails”