Posts Tagged ruby
Email validation in Ruby On Rails 3 or Active model without regexp
Posted by Hallelujah in email, rails, ruby on July 21, 2010
In Rails 3.0, you can use custom validator in your active_record model. So I wanted to manage email validations without regexp matching like others do. I find a new way to make this work thanks to ruby mail gem, a dependency of Rails 3.0 class User < ActiveRecord::Base validates :email, :presence => true, :email => [...]
How to translate your column fields and values with gettext in ruby on rails
Posted by Hallelujah in active_record, activerecord, gem, gettext, rails, ruby on July 7, 2010
I am proud to have published my first useful ruby gem. It is called gettext_column_mapping, you can check out the code in my github repository. I already released it as a gem through gemcutter/rubygems It is based upon Masao Mutoh (gettext and gettext_active_record) and Michael Grosser (fast_gettext and gettext_i18n_rails) works. Thanks to them History In [...]
Bundler default Gemfile and custom Gemfile, example of wirble
Posted by Hallelujah in bundler, gem, rails, ruby on June 29, 2010
Hi all, A simple trick I want to share with you if you are using Bundler (or rails 3) It matters if you want to install wirble gem in your workstation but not in your server Sometimes, you want to include some gem that are not mandatory for your application to run but you want [...]
Ordered Hash by keys
Posted by Hallelujah in Uncategorized on October 2, 2009
Recently, I have to implement my own Hash sorting method. Not really with Hash but with ActiveSupport::OrderedHash I don’t like the way ActiveSupport::OrderedHash behaves with sorting functionality. It just behaves like a simple Hash I would like that sort return an ActiveSupport::OrderedHash not an Arrray!!! Why is it called OrderedHash in this case ? I [...]
Class : to_s or not to_s ? That is the name !
Posted by Hallelujah in best practices, ruby on July 10, 2009
Many rubyist use the method Class#to_s instead of Class#name My purpose (shared by some programmers) is that to_s is just a String representation of the Class not its name!! Imagine you want to store an ordered list of inherited subclasses as a String so you can retrieve the inheritance order of each subclass. class Parent [...]
