Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3848120
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:39:17+00:00 2026-05-19T16:39:17+00:00

I watched http://railscasts.com/episodes/73-complex-forms-part-1 and http://railscasts.com/episodes/74-complex-forms-part-2 but it didn’t seem to work for me when

  • 0

I watched http://railscasts.com/episodes/73-complex-forms-part-1 and http://railscasts.com/episodes/74-complex-forms-part-2 but it didn’t seem to work for me when trying the code – my assumption is a lot has changed within rails since then. The second issue is I’m using JQuery.

Does anyone know of any tutorials online that might show an easier way to do this? I’ve already made one nested model form – so its really just the adding/removing fields dynamically part thats killing me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:39:18+00:00Added an answer on May 19, 2026 at 4:39 pm

    Here’s a simple example that shows how to send out multiple invites from single page. Some little details are missing but it might be enough to help. You can add and remove fields from the view via some simple jQuery. This code could be adapted to any kind of nested model situation. Hope it helps! 🙂

    InviteController.rb

    class InviteController < ApplicationController
      def new
        @invites = Invite.new
      end
    
      def create
        @invites = User.new(params[:user]).invites
        if @user.update_attributes(params[:user])
          return redirect_to root_url, :notice => "Your invite(s) were successfully sent!"
        else
          render :action => :new
        end
      end
    end
    

    User.rb

    class User < ActiveRecord::Base
      has_many :invites
    
      accepts_nested_attributes_for :invites
    end
    

    Invite.rb

    class Invite < ActiveRecord::Base
      belongs_to :user
      after_create :send_invite
    
      private
    
      def send_invite
        # Send e-mail...
      end
    end
    

    new.html.erb

    <% form_tag invites_path do %>
      <%= error_messages_for :object => @user.invites %>
      <ul id="invite-list">
        <%= render @invites %>
      </ul>
      <div>
        <%= submit_tag "Send Invite" %>
        <%= link_to "Add Another", "#add", :id => "add-another" %>
      </div>
    <% end %>
    

    _invite.html.erb

    <%= fields_for "user[invites_attributes][]", invite do |i| %>
      <li>
        <%= link_to("Remove", "#delete", :class => "delete-invite") %>
        <%= i.label :full_name, "Full Name" %>
        <%= i.text_field :full_name %>
        <%= i.label :email, "Email Address" %>
        <%= i.text_field :email %>
      </li>
    <% end %>
    

    application.js

    $(document).ready(function() {
      $('a#add-another').click(function() {
        $('#invite-list li:first').clone().find('input').val('')
        .end().appendTo('#invite-list');
      });
    
      $('.delete-invite').live('click', function() {
        if ($('#invite-list li').length > 1)
      $(this).parent().remove();
        else
      alert('You need at least one invite.')
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have watched railscast http://railscasts.com/episodes/236-omniauth-part-2 And tried to implement the code, everything worked well
so I've watched http://railscasts.com/episodes/43-ajax-with-rjs but I have a question: In my view I have
I've just watched Uncle Bob's presentation on Architecture software : http://www.cleancoders.com/codecast/clean-code-episode-7/show He talks about
I watched the http://www.subsonicproject.com/docs/Using_SimpleRepository screencast, but I am left wondering... how do you migrate
I've watched this video from Google I/O 2009: http://www.youtube.com/watch?v=AgaL6NGpkB8 where Brett shows microblogging example.
I am new to development. I followed step by step instructions from http://code.google.com/apis/maps/articles/flashmapinwpf.html to
so I watched this video on youtube ( http://www.youtube.com/watch?v=l_PLHuhlAJU ) on how to make
I watched the HttpClient progress code but I still have questions I couldn't find
Recently i watched a tutorial from youtube ( http://www.youtube.com/watch?v=8mwKq7_JlS8 ) The boy is typing
Having Watched this video by Greg Yound on DDD http://www.infoq.com/interviews/greg-young-ddd I was wondering how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.