Questions tagged [collection-select]
143 questions
1
vote
0 answers
Adding support for a three column join in a rails form
I'm working on an application where we have a survey, and the survey can be run at multiple locations, and each location could have a different staff member. Logically, makes sense to create a three column join table between Survey, Location, and…

Ryan Whitney
- 11
- 2
1
vote
1 answer
add to collection_select dynamically
I have 3 Models: Course, Unit and Plan.
relations are like:
Course has_many units
Unit belongs_to course
Plan has_and_belongs_to_many units
Unit has_and_belongs_to_many plans
In the create_plan page, I have a collection_select to get units of my…

MDK
- 680
- 1
- 9
- 20
1
vote
1 answer
How do I display error messages for validation on a collection select work simple_form?
I'm on mobile so don't have access to my code until later. But the basics are this: I have a simple_form to create/edit a listing on my site. Certain parameters are required. I use validates presence of in the model. When submitting the form, if I…

mano26
- 173
- 1
- 11
1
vote
1 answer
rails collection_select wrong number of argument error
I have a user_inputs table where I am storing the device subscription statuses under a column sub_status and these subscription statuses I want as drop down options Under the same name. Now after selecting one option from the drop down I want to…

mrgreen
- 15
- 4
1
vote
1 answer
How to dynamically add a (HABTM) collection_select + associated text_field in a Rails form?
For a personal invoicing app in rails I could use some advice on the following: In a new invoice form, how to dynamically add a new row consisting of a collection_select for products and an associated text_field for amount by clicking add new…

Jaakko
- 66
- 1
- 5
1
vote
0 answers
How can I show a radio button as selected with simple_form?
So I have a form with multiple inputs. for example:
<%= f.input :status, as: :radio_buttons, collection: [ 'available', 'pending', 'rented','coming soon','off-market'], checked: @base_address.status %>
<%= f.input :coop,…

mano26
- 173
- 1
- 11
0
votes
2 answers
Rails 7.0.4- form_for - collection_select with multiple options in edit action
I have three tables:
Staff
Staff_locations
Locations
Business case: Staff can work in multiple locations. Association between Staff and Location is done through staff_locations table. While creating Staff entry I am choosing locations that he/she…

Michal
- 3
- 2
0
votes
1 answer
RubyOnRails form.collection_select with data from second table
I am trying to use form.collection_select in an order form with data from a second model named products. I would like to use the field "product_reference" from the products table as selector in my HTML page.
When in the order form, I want to present…

pebwindkraft
- 133
- 6
0
votes
1 answer
Adding a button to collection_select options
I want to be able to make the first entry in my collection_select a button. In essence, if a suitable option is not available in the collection, the user should be able to click on the first option in the dropdown that will say 'add new...' to open…

rickyz
- 71
- 7
0
votes
1 answer
Prompt appears for only 2 of 3 Rails form (collection_select) elements
I'm a Rails beginner.
I have a form with several collection_select elements (Category, Bank Account, Vendor). The fields for Category and Bank Account correctly display the supplied prompt, but the Vendor field does not display its prompt. Instead…

chug
- 71
- 6
0
votes
2 answers
How to pass two attributes as the text_method to a collection_select in rails
I have a collection_select in a rails form that looks like this:
<%= form.collection_select :post_id, Post.all, :id, :title, {}, { class: "mt-1 block" } %>
What I can't seem to figure out from the docs or googling, is how to pass multiple…

Lee McAlilly
- 9,084
- 12
- 60
- 94
0
votes
1 answer
Using collection_select for saving ID of two classes in a booking through has_many and belongs_to association throws error 'must exist' when saving
I am building a simple booking application for learning rails. I scaffolded people, cars and bookings.
Now when I try to create bookings I get
2 errors prohibited this booking from being saved:
Person must exist
Car must exist
Code
car.rb
class…

OuttaSpaceTime
- 710
- 10
- 24
0
votes
1 answer
Collection_select helper cannot build disabled html tag in ruby on rails erb
Ruby on rails docs says you can add html options to tag helpers. The code below is not working. My select box cannot shown disabled. Is there anybody knows why?
<%= form.fields_for :journal_doc_analytics do |analytics| %>

Sercan Tırnavalı
- 187
- 2
- 9
0
votes
1 answer
Option from collection_select creates a new one on submit - Rails 5
Today I've been working on a HABTM association between my Plugins and Categories. I got it almost working, but run into trouble with the collection_select.
I have a select in my form and I succesfully call all the existing Categories, but when I…

Ernest Mistiaen
- 29
- 4
0
votes
0 answers
Rails collection_select different selected attribute
I have a collection_select with options from other model, and I need to show in the dropdown and in selected value different attributes. I.e I need to show in dropdown object.title but the selected value should show object.code.
I have a…

O.Vykhor
- 461
- 1
- 5
- 18