Hi, Could you look at some code I created? I don''t know if it''s good... or if it could be better. Especially the controller. I couldn''t find a way to let the declaration_payers be automatically saved. declarations_controller.rb: def create @declaration = Declaration.new(params[:declaration]) unless @declaration.save @users = User.find(:all) render :action => ''new'' return false end @declarations_payers = params[:declarations_payers] @additional_persons = params[:additional_persons] #If there are payers, add them if @declarations_payers @declarations_payers.each_value { |user_id| #Add new object @declarations_payer = DeclarationsPayer.new #Set user_id variable (from post) @declarations_payer.user_id = user_id #Add aditional persons (from post) @declarations_payer.additional_persons @additional_persons[user_id] #Add the object to the declaration object @declaration.declarations_payers << @declarations_payer } end flash[:notice] = ''Declaration was successfully created.'' redirect_to :action => ''list'' end _form.rhtml: <%= error_messages_for ''declaration'' %> <!--[form:declaration]--> <p><label for="declaration_amount">Amount</label><br/> <%= text_field ''declaration'', ''amount'' %></p> <p><label for="declaration_description">Description</label><br/> <%= text_field ''declaration'', ''description'' %></p> <% unless @users.nil? %> <p> <% for user in @users %> <label for ="<%= ''user_ids[''+user.id.to_s+'']'' %>"><%user.fullname %></label> <%= check_box_tag ''declarations_payers[''+user.id.to_s+'']'', user.id, @declaration.users.include?(user) %> met <%= text_field_tag ''additional_persons[''+user.id.to_s+'']'', @declaration_payers[user.id], ''size'' => 1 %> additionele personen <br /> <% end %> </p> <% end %> <!--[eoform:declaration]--> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---