Category: Rails
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 [...]
Howto Display a GitHub Changelog in your application
June 27th, 2009, 2 Comments
In this post I will show you a simple way to display a list of your GitHub changes inside your application.
This can be useful for so many reasons, not least helping to create a better relationship between your users and your developers. This obviously would not be applicable in all circumstances, but in many cases, [...]
Set your Rails Environment Globally
June 20th, 2009, Comments Off
In much of the rails documentation it is suggested that when you want to run a task in a specific environment, you should set the RAILS_ENV environment variable on the command line where you are running the task.
For example, assume you want to run rake db:migrate on the production system (should be done automatically [...]
Setting User’s Locale Based on Domain Name In Rails
June 18th, 2009, 2 Comments
In this tutorial I will show how you can quickly set the user’s locale based on the domain name they use to access your website. Let us assume you have your app, and you also own your own domain in several different country TLD’s, let’s say, you have example.com (main site), example.co.uk, example.fr, example.it example.es, [...]