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

  • Home
  • SEARCH
  • 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 8625467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:47:37+00:00 2026-06-12T07:47:37+00:00

I am having trouble with my first join-table for a many to many relationship.

  • 0

I am having trouble with my first join-table for a many to many relationship.

class Category < ActiveRecord::Base
  has_and_belongs_to_many :users
end

class User < ActiveRecord::Base
  has_and_belongs_to_many :categories
end

And I have added a join table:

create_table "categories_users", :id => false, :force => true do |t|
  t.integer "category_id", :null => false
  t.integer "user_id",     :null => false
end

Can someone point me to an example of the form that I would use to add a user to a category? Do I need a separate restful controller for ‘categories_users’? I have an impulse to add method to my category controller called “add user”, but I’m not sure if that is wise for an otherwise RESTful controller.

  • 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-06-12T07:47:38+00:00Added an answer on June 12, 2026 at 7:47 am

    I’m using simple_form and I finally found in the documentation there what to do. So using simple_form, the form would look like this:

    <%= simple_form_for [:admin, @festival, @category] do |c| %>
      <%= c.input :name %>
      <%= c.input :description, input_html: { cols: 100, rows: 3, class: "span6" } %>
      <%= c.input :takes_submissions %>
      <%= c.association :users, label_method: :full_name, label: "Choose curators" %>
      <%= c.button :submit %>
    <% end %>
    

    No need to add a controller or separate form. Yay!

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

Sidebar

Related Questions

I'm having trouble saving a many-to-many relationship with nhibernate. I searched and looked at
I'm having some trouble with getting this SQL right. There is a one-to-many relationship
I made my first class and I'm having trouble converting the objects back into
First of all I am having trouble with the concept of a mathematical Vector
I am having trouble getting ASP.Net MVC 4 running on IIS 6. First, i
I am having trouble getting minizip to work on android. I first tried to
I'm writing my first interactive animation in Flash CS3 and I'm having trouble locating
I'm setting up my first symfony project, and am having trouble with the schema.
I am playing with my first PhoneGap/Android app, and am having trouble triggering $.mobile.changePage()
sorry about the funky title, I was having trouble coming up with one. First

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.