Questions tagged [collection-select]
143 questions
0
votes
1 answer
ruby on rails drop down menu selected
There are many posts about this... and I'm pretty sure my syntax is right, but for some reason
:select => "some value or text" is not working for me.
here is my form:
=form_for(@pet) do |f|
=f.label :name
=f.text_field :name, :placeholder =>…

rikkitikkitumbo
- 954
- 3
- 17
- 38
0
votes
0 answers
Rails: saving value selected in collection_select in the view
I'm Rails newby, and I spent most of today trying to find an answer to my problem, but I couldn't really figure it out. I think this is a common problem a lot of people may be looking for straightforward answer, so here goes:
All I want to do is use…

msadoon
- 143
- 2
- 11
0
votes
1 answer
Rails 4 Ecommerce App using collection_select/select: how to correctly implement?
I have a Product model with the following columns:
name:string
price:integer
I also have a cart model, line_item model, an orders controller: pretty basic but you get the idea.
What I need to do (and have done) is add size (since it's for tshirts)…

Nubtacular
- 1,367
- 2
- 18
- 38
0
votes
1 answer
Rails conditional_select for nested attributes
I'm trying to setup the following: A User has many Groups through Memberships, a Group has many Events, and an Event has many Posts.
On my view to show a group with all of its events, I want a user to be able to write a new post by selecting the…

kyle
- 87
- 1
- 1
- 8
0
votes
2 answers
Rails - Drop down list with 'other' that allows creation of new model object
I currently have a rather complicated _request_form for creating new Requests in my website. Currently, when creating a request, employees must choose their name from a dropdown menu like so:
<%= f.collection_select :name, Employee.all(:order =>…

Darkstarone
- 4,590
- 8
- 37
- 74
0
votes
1 answer
Rails odd error when submitting collection_select w/ unrelated validation
I've got a working form that properly saves all attributes including a collection_select. However, when I add validates :title, presence: true and try to submit, I get
undefined method 'map' for nil:NilClass
My new action:
class ItemsController <…

Kevin Brown
- 12,602
- 34
- 95
- 155
-1
votes
1 answer
why i can't to use this code f.collection_select
I would like to replace this line code:
from:
f.collection_select(:status, Status.all, :id, :name
to:
f.collection_select(:status, [{id: 1, name: "status1"}, {id: 2, name: "status2"}], :id, :name
But i got error:
undefined method `name' for…

Oleg Shevtsov
- 73
- 2
- 12
-1
votes
2 answers
Populate textfields on new form from another model's existing records on select rails
I have a DefaultTemplate model with existing records in it. I have another Template model where i have a collection_select with DefaultTemplate's Records.
What i want to do is that as soon as user selects one of these options, its associated data…

Aakanksha
- 956
- 1
- 13
- 26