Questions tagged [collection-select]
143 questions
4
votes
0 answers
How to use a Rails collection select inside a block
I'm using Simple Form in my Rails 6 e-commerce inventory tracking, and I need to have multiple collection selects in my form that appear based on an association.
Here's the data model:
Product
has_many Option(s)
Option
has_many Choice(s)
…

Lee McAlilly
- 9,084
- 12
- 60
- 94
4
votes
1 answer
Rails 5: How to pass collection_select values through strong_params in a fields_for?
I’ve tried every video and article and still can’t find a solution to getting fields_for collection_select values to whitelist in strong_params. I’ve spent days trying to figure this out (and asked a number of people). If anyone could take the time…

Dog
- 2,726
- 7
- 29
- 66
4
votes
1 answer
rails 4 collection_select multiple nested attributes not saving properly
I'm new to rails and I'm having trouble saving nested attributes of a join table using collection_select. I have models post, tag, and post_tagging. post_tagging is a join table.
I want to set multiple tags per post so I attempted to use a…

Justin
- 43
- 1
- 4
4
votes
1 answer
How can I put an "add new" link in a collection_select field in Rails
I want to build a sales_opportunity in my Rails app. The sales_opportunity belongs_to a User and also to a Company. The code works fine as it currently stands, and the form permits a user to select a company to link the sales_opportunity with based…

Zoinks10
- 619
- 6
- 21
4
votes
1 answer
collection_select with select2 and bootstrap: undefined is not a function
In a Rails 4.1 app, I have a collection select that is loaded from a hash. I would like to use the select2 boostrap styling, but it doesn't seem to be working.
I have included the select2-rails gem, and updated application.js and application.css as…

port5432
- 5,889
- 10
- 60
- 97
3
votes
1 answer
Filter by user.id using collection_select for drop down in form
My first SO posting. Finally found something that has stumped me and after 6+ hours, I've decided I need some help, before I lose my mind.
I'm trying to use collection_select for a drop down list in a field to create a new record in a second model.…

kchucke
- 35
- 4
3
votes
2 answers
Add class to collection_select on Ruby On Rails formulary
I'm using a form for create a record in RoR. I've dropdown menu and I don't know how to add a class for styling this element.
Code:
<%= f.collection_select :id, TipusProducte.order(:nom),:id ,:nom, include_blank: false, class: "btn btn-secondary…

Xavi
- 67
- 7
3
votes
2 answers
How get the value of a collection_select within the same html.erb form itself
I have a form with this collection_select
<%= collection_select :bmp, :bmpsublist_id,
Bmpsublist.where(:bmplist_id => @bmp.bmp_id), :id,
:name,{ :required => false,
…

Santi Gallego
- 202
- 1
- 18
3
votes
2 answers
Customizing the text in a collection_select dropdown
I have a collection_select dropdown that has a dropdown of names like this:
<%= f.collection_select(:person_id, Person.all, :id, :name) %>
But I have a foreign key on a person that points to a group they are part of. In the dropdown I want to show…

Arel
- 3,888
- 6
- 37
- 91
3
votes
1 answer
rails4 collection select with has_many through association and nested model forms
I have a rails4 app. At the moment my collection select only works if I select only one option. Below is my working code. I only have product form. Industry model is populated with seeds.rb. IndustryProduct is only use to connect the other 2…

Sean Magyar
- 2,360
- 1
- 25
- 57
3
votes
0 answers
Creating new record through collection_select rails 4
I am a newbie in ROR and I want to create new record from collection_select if the existing collection does not have the record needed
I tried this solution but it doesn't work for me
Rails' collection_select helper method and the "Create item"…

rota90
- 249
- 1
- 4
- 17
3
votes
1 answer
Use an image for radio button label in Rails 4
I am trying to use the helper collection_radio_buttons to show an image as a label, and want to save the image_id to the model so that I can retrieve the url, so far I have come up with this which shows a radio button and the image_url as the…

Richlewis
- 15,070
- 37
- 122
- 283
2
votes
0 answers
How to set a form for nested attributes with collection selection?
I am trying to configure a form for nested attributes with a selector on RoR, but it seems I am doing it wrong.
I am trying to create a new affaire with nested_attributes contributions.
Each contribution belongs to a skill which needs to be…

montyreno
- 21
- 2
2
votes
1 answer
How to make a POST to a route from collection_select in helper Rails
I'm a newbie in Ruby on Rails.
This is the helper method that I call from the html.
def select_user_role (user)
@user = user
collection_select(:user, :role, User.roles.to_a, :first, :first, {}, {
data: {user_id: @user.id},
…

spassador
- 393
- 1
- 12
2
votes
1 answer
collection_select concat firstname and lastname with same id
I'm trying to get the firstname(s) and lastname(s) which have the same id.
My Table Schema looks like this:
| id | nameable_id | nameable_type | value | type |
| 1 | 2 | Person | John | Firstname |
| 2 | 2 | Person…

toxic2302
- 23
- 4