pingu
pingu

Reputation: 8827

Form for submitting nested devise user data

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?

Upvotes: 0

Views: 96

Answers (1)

dbKooper
dbKooper

Reputation: 1045

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

Upvotes: 1

Related Questions