Tag: Rails
Quick and easy static pages in Rails
February 10th, 2010, 16 Comments
Sometimes you have a Rails app, the core functionality is not a CMS, and you need to add some static pages to your app that don’t get changed often, eg, an about us page, privacy policy, etc.
This post shows you a quick and easy way to do that in about 60 seconds, without using a [...]
Google Analytics and Rails in 60 Seconds
July 8th, 2009, 3 Comments
This quick post will show you how to install Google Analytics into your Rails powered website in less than 60 seconds.
Before I start, I need to ask you…
In real terms, what is each visitor to your website worth? Do you know? Would you like to find out how you can find out?
What is [...]
Rails: Black Box Testing Complex Models
July 4th, 2009, 8 Comments
In this article I will show you how you can perform complete end-to-end testing of very complex models using a method called Black Box Testing. I will demonstrate a solution that scales to hundreds of tests and upwards, without having to write any additional code or fixtures for each one.
The method I am going to [...]
Correct Format Plugin Released
July 4th, 2009, Comments Off
I have released a new Plugin for Rails, called Correct-Format.
Github URL: github.com/mendable/correct-format
This plugin allows you to automatically correct simple user input mistakes
and format user-input without raising an ActiveRecord Error and without
inserting inconsistently formatted data into your database. Using this
plugin will enhance the usability and user-friendlyness of your application
and increase your data integrity.
You can automatically:
Make a [...]
Understand Named_scope in 60 seconds
June 28th, 2009, 1 Comment
Named scope was introduced in Rails 2.x, it allows you to filter a selection of records easily and repeatedly, without having to write finder SQL all the time.
class Customer < ActiveRecord::Base
has_many :carts
end
class Cart < ActiveRecord::Base
belongs_to :customer
named_scope :completed, :conditions => ["NOT ISNULL(completed_at)"]
end
Example of self-model scoping and finding:
# All completed carts [...]