Questions tagged [collection-select]

143 questions
0
votes
1 answer

Two collection_select that save as two different records

I have this: <%= f.collection_select :category_ids, Category.all, :id, :name, {} %> inside my form and it creates the record no problem, however I'm lost on how to make more two or more records inside the same form, all the things I try either just…
Bluespheal
  • 123
  • 1
  • 10
0
votes
1 answer

Rails Form collection_select not saving to database

I am a rails newbie and building a little application to help with my work. I have client, site and quote models and controllers with views set up. I have created a form on the quote model that pulls data from the other two models in a…
Jeremy Bray
  • 444
  • 5
  • 18
0
votes
0 answers

Why is a permitted variable throwing an undefined method error?

Going from ruby-2.1.2@rails-3.2.18 to ruby-2.4.0@rails-5.0.2. The following stanza throws an undefined method `reqdb' for # <%= form_for :page, :url => {:odbinsight => :reqdb} do |f| %> <% if @mywkbks != nil %> <%= f.collection_select…
0
votes
2 answers

DropDown with name from another model rails

I have students that belong to a submission and I need a drop down that shows the students so the user can choose one of them. I tried to use this but it's not working: <%= collection_select(:student_name, :submission_id, Submission.all, :form_id,…
0
votes
2 answers

How to change background color of collection_select items in Rails?

How can I style the visual drop-down of a collection select in Rails? I want to change the background color of individual items in the drop-down, with the color derived from an attribute in the Affiliation object. Here is the current…
0
votes
1 answer

How to show more attributes in each element of the collection with collection_select

I have this with simple form: = simple_form_for(Note.new, remote: true) do |f| = f.collection_select :dance_id, current_user.dances.includes(:style).all, :id, :style_name, {prompt: "Please select dance"}, {class:…
user5900658
0
votes
0 answers

How to scope the options of one select field by the option that is selected in another (Rails 4)

I'm trying to figure out how to scope the options of one select field after an option of another select field is selected. Once a board is selected in the 'boards' select field, only the lists that belong to that board should appear in the 'lists'…
0
votes
1 answer

Ruby on Rails error when validates_uniqueness_of using collection_select

First, sorry for my bad English. I'm still learning. I have 3 tables in my DB: Problem has_many :registers has_many :solutions, through : :registers Solution has_many :problems has_many :problems, through : :registers Register belongs_to:…
0
votes
1 answer

RoR: Collection_select undefined method

I previously ask this question but messed up the OP. The official docs for this are not the best and a little confusing. I am trying to gather options from a feedback table and render them in a dropdown on a form and then save them in a table called…
Co2
  • 343
  • 1
  • 14
0
votes
1 answer

Rails - collection_select is converting output to a string instead of an integer (and not saving)

I am having a problem with my collection_select in rails and I can't seem to find what's causing it. I have 3 models, users, projects and budgets. Users can have multiple projects, and projects can have one budget. Each budget has one project. I…
Stephen
  • 187
  • 12
0
votes
1 answer

Rails options_for_select set default

I have searched everywhere for this, and can't seem to find an answer. I am trying to set the default value of my Language dropdown to English. <%= f.collection_select(:native_language, Language.order('language ASC').all, :language, :language,…
gwalshington
  • 1,418
  • 2
  • 30
  • 60
0
votes
1 answer

collection_check_boxes - what is the correct setup

Model class Rfq < ActiveRecord::Base belongs_to :purchase belongs_to :supplier belongs_to :customtemplate end class Purchase < ActiveRecord::Base belongs_to :order #Products has_many :purchase_products, dependent: :destroy …
Michal
  • 139
  • 3
  • 14
0
votes
2 answers

print two values in collection_select (Rails Forms)

For my form, I have this: <%= tag_field.collection_select( :id, Material.order(:name), :id, :name, :prompt => "-select-")%> This prints my materials names. example: Cat Cat However, this is not helpful because the materials have the same…
cats
  • 55
  • 7
0
votes
1 answer

Rails dropdown menu to select object for text_field

I am building a rails form and have an interesting problem I am trying to solve. I can't seem to find anything online to point me in the right direction. Thank you. Is it possible to use a dropdown menu to select the :object_name for a text field?…
ncarroll
  • 108
  • 1
  • 1
  • 10
0
votes
1 answer

How do I construct a f.collection_select menu with custom options (not from a database)?

I'm using Rails 4.2.3. I would like to construct a select menu in my form, in which both the name and value are the same option and I would like to construct the options from an array. I tried this <%= f.collection_select :unit,…
Dave
  • 15,639
  • 133
  • 442
  • 830