Friday, 29 December 2006

Rails: Staying away from Enums in Migrations (ruby)

I was fiddling with migrations, and found these regarding the use of MySQL-ish ENUMs in Migrations:

Basically, ENUMs aren't supported, and using Validations might be a good work-around, but is dependent on you putting (and keeping) all of the logic in your Rails app. If you need to go cross-app (with some other thing that ain't rails), then use CHECK or other DB constraints to enforce desired values.

posted by erin at 29 December 2006, 02:48 PM (add comment)
Tuesday, 11 July 2006

Rails: Printing validation errors as flash notices (ruby)

I am quite sure someone has already found this simple solution, but when I poked around, I couldn't find it.

Here is my snippet to print out the error messages resulting from a validation as a flash notice:

  if @user.save 
    flash[:'notice'] = "New user saved successfully."  
  elsif !@user.errors.empty?
    flash[:'notice'] = "Could not save new user: " 
        << @user.errors.full_messages.join("; ")
  end
posted by erin at 11 July 2006, 06:43 PM
Sunday, 5 March 2006

Ruby and Rails. (ruby)

So. I'm fiddling. again. with Ruby on Rails. because it's trendy.

I have to say, it's also handy. Very nice not to have to write the entire DB framework just to make an app! The problem that I have is I'm such a habitual programming dork that I find Ruby's syntax a little odd...

posted by erin at 5 March 2006, 01:53 PM (add comment)

ARCHIVES

These are archived (old) articles, see:

About me

Ebullience
Myriad

About this site

The Archives
What is this blog stuff?
Why you should blog.

Sections
Categories: code

Etc.

[code: ruby]