Posts Tagged ‘ruby on rails’

A voting extension from scratch for Rails 3 (Part 4 – models and migrations)

Better late than never … finally Part 4 of the blog series about developing MakeVoteable, a voting gem for Rails 3. In the last episode we took a deeper look how to get the logic inside our gem. In this episode we focus on the model this logic acts on. As we use ActiveRecord to [...]

A voting extension from scratch for Rails 3 (Part 2 – Testing environment)

In the last episode we created the basic structure for the make_voteable gem. With “test first” in mind we now set up our RSpec testing environment for developing the make_voteable gem. We already installed RSpec at the beginning of this blog series. First we need to create a testing folder (named spec) directly under the [...]

A voting extension from scratch for Rails 3 (Part 1 – Overview and setup)

This blog series is about creating a voting extension for Ruby On Rails. There are already some others voting extensions available, but none is currently up-to-date 1 or ActiveRecord compatible 2. So let’s build one from scratch. It is also (or maybe even more) a blueprint of current best practices on how to build those [...]

Check your params

I just asked myself (and the community) where validating and cleaning up the GET/POST parameters would fit best in Rails. lebreeze at Stackoverflow suggested a sanitize_params method that is called by a before_filter in the ApplicationController. I agree that the ApplicationController is a good place, but I don’t like the fact that it is called [...]

Index external models with Sunspot/Solr

Lately I wanted to index all tags of ActsAsTaggableOn for full text search and autosuggestions using Solr resp. Sunspot. The ActiveRecord models of ActsAsTaggableOn are unfortunately not directly accessible as they are located in the ActsAsTaggableOn gem. Fortunately that is pretty easy to solve by using metaprogramming techniques. So I added an additional initializer named [...]