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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:37:50+00:00 2026-05-29T22:37:50+00:00

I have collection_select in one of my views, which properly creates a HTML <select>

  • 0

I have collection_select in one of my views, which properly creates a HTML <select> menu, but when I select an option it does not save in the database. In the same view I have other fields from the same db table and they save up. Here are my models:

class TrainingPart < ActiveRecord::Base
  belongs_to :activity
  belongs_to :training  
  accepts_nested_attributes_for :activity, :allow_destroy => true
end

class Activity < ActiveRecord::Base
  has_many :training_parts 
end

The partial is:

<div class="part">
  <%= f.label :activity, "Activity" %>
  <%= collection_select :training_part, :activity_id, Activity.all, :id, :name %>
  <%= f.text_field :activity_id %>
  <%= f.text_field :amount %>  
</div> 

The amount field works fine.

EDIT: I don’t use attr_accessible in any model, so all of the fields in all tables are accessible. (reference: Rails mass assignment definition and attr_accessible use)

  • 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-29T22:37:52+00:00Added an answer on May 29, 2026 at 10:37 pm

    I managed to do it. It turned out that I had 2 mistakes:

    1) I had to remove <%= f.text_field :activity_id %> from the view as this was the field, which I was trying to set with the select menu.

    2) I should’ve used f.collection_select instead of collection_select

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

Sidebar

Related Questions

So I have 2 views: the first one generates the html on request, the
I have a tableviewapplication, wich when the user select one view it needs to
I'm having a problem similar to but not quite the same as one I've
I to do connection and have error. from u in db.aspnet_users where u.UserName.Equals(email) select
I have some legacy SQL (SP) declare @FactorCollectionId int; select @FactorCollectionId = collectionID from
I have an SSIS package that does the following: Selects the connection strings from
I have a collection of models, each of which is attached a view. The
I have a Model Category which has name:string categoryId:integer parent_id:integer the categoryId doesnt matter
I have a few problems but I'm going to start with the first and
I'm working on a BackboneJS application. One of the cases I'm working on, which

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.