Question

I have the following models:

class User < ActiveRecord::Base

  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable, :encryptable

  belongs_to :club
end

and

class Club < ActiveRecord::Base
  has_many :users

  accepts_nested_attributes_for :users
end

given that "accepts_nested_attributes_for" must go on the "has_many" side, how do I construct a nested form that accepts nested, devise, user data please?

Was it helpful?

Solution

Ok. I think it should work:

controller:

@users = @club.users.build

Form :

 form_for @club
  fields_for @users |fr|
    @users.each do |usr|
      text_field :email
      text_field :password
      text_field :pass_conf...
          other fields
    end
   end
   submit
  end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top