Tag Archives: validations

Change database column names for form validations in Rails

When you use validations in Rails, db column names are used as ‘keys’ for error messages. This is usually the preferred way to go about it because this maps nicely to the form fields. However, if you use a virtual attribute this may not be the case. For example, I have a ‘password_crypted’ field in [...]
Posted in Ruby on Rails | Also tagged , , | Leave a comment

Problem slash Bug in Rails with attr_accessor and Datetime Select Fields

Looks like there is a problem with using the attr_accessor method with datetime form fields http://dev.rubyonrails.org/ticket/8983 In Rails 2.3.2, for me at least, the problem seems to be popping up again. While trying to process a date for credit card validation, I keep getting a ‘nil.klass’ error. Sure enough, remove the datetime select from [...]
Posted in Ruby on Rails | Also tagged , , , | Leave a comment

Trouble Using Attr_Accessor in Rails Models and Forms

You might use the attr_accessible method to create getters and setters for a class that has attributes which don’t map directly to corresponding fields in a database. For example let’s take the scenario where you are processing a credit card transaction. You don’t want to save the credit card details, such as card number and [...]
Posted in Ruby on Rails | Also tagged , , , , , , | Leave a comment