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 6007989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:45:39+00:00 2026-05-23T01:45:39+00:00

My application has a form to update an Event. I’d like to be able

  • 0

My application has a form to update an Event.

I’d like to be able to add an existing user to this event with a nested form.
I use the Ryan Bates “nested_form” gem.

It works great to delete an existing user but how can I add an existing one just with his username?

Model :

class Event < ActiveRecord::Base
 has_many users
 attr_accessible :users_attributes
 accepts_nested_attributes_for :users, :allow_destroy => true
end

Controller :

def update
  if @event.update_attributes(params[:event])
   redirect_to @event
  else
   render :edit
  end
end

View :

= f.fields_for :users do |users_form|
  = users_form.text_field :username
  = users_form.link_to_remove "Remove user"
= f.link_to_add "Add a user", :users
= f.submit

Thanks in advance !

  • 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-23T01:45:40+00:00Added an answer on May 23, 2026 at 1:45 am

    If you want many users coupled to many events, you will need has_many :through relationship. In that case, a relation builds a new row in the database, and in that case it is easier to use the cocoon-gem to dynamically link and unlink pages.

    I answered a very similar question, also coupling events and users, here.

    If you have any more questions, let me know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm tweaking a WinForms application. This application has a Form that contains a PropertyGrid
I have an application that has a main form and uses an event handler
My android application has several warnings of the following form when I run it
I have a Delphi application that has a document browser as the main form.
I have a Windows application that has 2 Forms . From one form I
I have an application with multiple forms, each form has the same icon, so
I embedded .NET's WebBrowser into a form that has some other buttons. The application
I have a Windows Form application. Version 1 of my app has been released
Application has an auxiliary thread. This thread is not meant to run all the
My application has a need to let the user choose a date from a

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.