Hi...I am only 1 day into Rails, so please forgive me if this is a
lame question!

I have the following models:

require 'books_projects.rb'

class Project < ActiveRecord::Base
  has_many :book_to_projects
  has_many :books, :through => :book_to_projects
end

require 'books_projects.rb'

class Book < ActiveRecord::Base
  has_many :book_to_projects
  has_many :projects, :through => :book_to_projects
end

In my projects controller, I am trying to do this:

@projects = Project.find(:all, :include => [:books])

My hope is to get a nested data structure back that looks something
like:

projects: [
  {
    ..,
    books: [
        {
          ..
        },
        {
          ..
        }
    ]
  }
]

But that does't work. How can I achieve this?

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to