M_Bougie
(M Bougie)
1
Can you change something in this kind of relationship, because it
works great in previous version?
NameError (uninitialized constant User::Post)
class Post < ActiveRecord::Base
belongs_to :user
...
class User < ActiveRecord::Base
has_many :posts
accepts_nested_attributes_for :posts
...
class PagesController < ApplicationController
def index
@user = User.find(6)
@posts = @user.posts #############ERROR
end
radar
(Ryan Bigg)
2
Please ask this question on Rubyonrails-talk. It seems like you are defining your Post model in a file incorrectly named / located.
Thank you for your reply
The code I gave you worked with 3.0.9.
RAILS_ROOT/app/models/post.rb
RAILS_ROOT/app/models/user.rb
RAILS_ROOT/app/controllers/pages_controller.rb
I have difficulty when i specify @foo.first.key instead of @foo[0].key
too.
...All my files kept their names from previous versions, but rails
3.1.0.rc4 complain.
If you have an idea I'll take it, otherwise I'll try on Rubyonrails-
talk....