problems upgrading devise in an rails 2 to rails 3 migration

I ran into some problems upgrading devise from 1.0.x to 1.3.x. to use passwords besides bcrypt you have to made 2 changes: in config/initializers/devise.rb config.encryptor = :sha1 (for devise 1.0.x compatibility) in User model (or whatever model calls devise) call devise with both :database_authenticatable and :encryptable you can tell you have issues with this if you see …

Continue reading ‘problems upgrading devise in an rails 2 to rails 3 migration’ »

Accessing MS SQL Server from Rails without ODBC

I found myself looking through the code for activerecord-sqlserver-adapter and noticed a new mode called “dblib”.  It turns out this mode can be used when using the tiny_tds gem along with FreeTDS to avoid using ODBC altogether.  I decided to try it out on a project and have found it to work very well so far.  The …

Continue reading ‘Accessing MS SQL Server from Rails without ODBC’ »

Ruby regexp surprise: w is not equivalent to [0-9A-Za-z_]

Despite ample documentation to the contrary I was surprised to learn that by default ruby matches w to all unicode characters.  This lead to some strange results in one of my apps where unicode quotes were present and matching w.  I found the solution is to use /w+/n to specify the n kcode rather than …

Continue reading ‘Ruby regexp surprise: w is not equivalent to [0-9A-Za-z_]’ »

Working with devise for Rails authentication

I’ve begun using devise for authentication for my various Ruby on Rails applications.  It is based on warden which seems a sensible choice.  There is also a fairly large community and active development.  Devise plays nice with authorization libraries such as CanCan and can be integrated with OmniAuth for oauth/oauth2 authentication.  I’ve run into a …

Continue reading ‘Working with devise for Rails authentication’ »

Learned a lot about nested attributes and Rails

It’s been a frustrating night trying to figure out how accepts_nested_attributes_for, autosave, dirtyness, and Rails versions all fit together.  Going to try and summarize my findings and hopefully I’ll get it right. accepts_nested_attributes_for turns on autosave autosave will cause any loaded associations to be saved when save for the parent object is called the key …

Continue reading ‘Learned a lot about nested attributes and Rails’ »