
attractive, usable web applications
Richard's Blog - Design, coding and life in Japan
Get an array of associations for a rails model
Submitted by Richard on Tue, 01/26/2010 - 10:05This 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
- Why you should use Rails 3 and not Django 5th Sep 10, 12:28
- Doctrine 2 and why you should use it! 29th Jul 10, 15:23
- How to localize your main blog listing page using Drupal 26th Jun 10, 11:46
- Creating Rails like template helpers in Django 24th Jun 10, 22:01
- Error: No module named messagesdjango.contrib.contenttypes 22nd Jun 10, 22:00
Post new comment