0

I have a question on rails3 nested_form.
These are my two models:

class User
   belongs_to :shop
   accepts_nested_attributes_for :shop
end

class Shop
  has_many :users
end

In my register view(i am using Devise):

form_for(resourse,:url => registration(resource_name)) do  |f|
   =f.fields_for :shop do |s|
     =s.text_fields :name

but i get nothing for this form. What should i do?

1
  • Are you using simple_form or formtastic? Commented Jul 16, 2011 at 20:40

1 Answer 1

2

You need to add some objects first to it. Use build method on model in controller.

Example:

@shop = Shop.new
3.times { @shop.users.build }

More informations at Railscasts. AJAX is used in second part of this video.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.