front and back-end web development, Leeds, UK


Richard's Blog - Design, coding and life in Japan

Richard

Blog Archive: January 2010

Get an array of associations for a rails model

This one got me stuck as I couldn't see any such methods in the ActiveRecord API, but with a little help from Google Ruby on Rails: Talk group I managed to work it out.

ClassName.reflect_on_all_associations.collect {|assoc| assoc.name}

Easy as that

Tags:

Recent Blog Posts