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:
- Enum fields in migrations? [rails.techno-weenie.net]
- HowtoUseSetAndEnumColumns [wiki.rubyonrails.com]
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.
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
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...
