Questions tagged [collection-select]
143 questions
1
vote
1 answer
Dynamic Collection Mapping: Add missing records in collection
I have the following
->select(DB::raw('source as Source, customer as Customers, COUNT(*) as count'))
->groupBy('source', 'customer')
->get();
I get the follwing results
Illuminate\Support\Collection {#460 ▼
#items: array:4 [▼
0 => {#466 ▼
…

Rakesh kumar
- 609
- 8
- 20
1
vote
1 answer
Can't make Stimulus JS data-action in collection_select Rails 6
I'm new to Stimulus JS. I'm a little stuck trying to make a simple event fire using collection_select in a form (created with rails g scaffold).
Here's my dropdown-controller.js (stimulus) file:
import { Controller } from "stimulus"
export default…

Ignacio
- 37
- 1
- 9
1
vote
0 answers
Can't seem to submit collection_select and receiving Unpermitted parameter: :hero_id
Sorry for the messy post, my first time posting. I have been trying to get this collection submit to work, but every time I press create report button I have it goes back to the screen and puts out Unpermitted parameter: :hero_id in the rails server…

MarrixRed
- 57
- 6
1
vote
1 answer
form_for collection_select not showing saved selections on edit
I have a form that I'm using for both new and edit. The form has fill-ins for product name, description, etc.
Also, the user can either select an item from the nested drop down (collection_select), or they can create a new item. On "new" the form…
user7058619
1
vote
1 answer
Collection_Select Does Not Respond to Input_HTML: {Multiple: True}
I am attempting to create a feature where users can add an existing record, recipe, to a collection of records, menu. I am using collection_select with a simple_form to allow users to select multiple records from a list however, the form is not…

dsteinbr1
- 77
- 11
1
vote
1 answer
How to append another attribute to collection_select?
I am trying to add a boolean attribute (third_party) to my current collection_select that currently just shows name:
<%= f.label :project_component_id, class: "form-label" %>
<%= f.collection_select…

Shnarf
- 39
- 1
- 9
1
vote
1 answer
Multiple attribute in collection_select in Rails
I am trying to allow for multiple value selection from a collection in a Rails form. The field is working but does not allow for multiple selections (once an alternative option is selected the previously selected is unselected). I am using Bootstrap…

dollarhino
- 45
- 1
- 4
1
vote
0 answers
Show active record entries inside 'f.collection_select' on edit (RoR)
I have a Rails 5 app.
template _form
- if current_user&.super_admin
.form-group.has-feedback
.text-muted
= f.label 'Which users should see this?'
= f.collection_select(:user_templates, User.all, :id, :name, { include_hidden: false },…

Andy
- 531
- 1
- 4
- 19
1
vote
1 answer
Getting unpermitted parameter using collection_select with multiple => true
I have two models with no associations between them. I am fetching the list of names as options for selection to the primary model. Collection_select without multiple => true works as expected. But when i add multiple i get the unpermitted…

Gunther Gib
- 117
- 10
1
vote
1 answer
Rails use collection_select to assign equipment to site
I have a very simple rails application that collects "equipment" and assigns it to a "site"
class CreateEquipment < ActiveRecord::Migration[5.0]
def change
create_table :equipment do |t|
t.string :site_name
t.string…

Jeremy Bray
- 444
- 5
- 18
1
vote
1 answer
Rails: Using an object in an array as the object argument for collection_select
I need to use an object in an array as the object argument for collection_select in a form using a form_tag helper but my params hash isn't formatting correctly.
Example:
<%= form_tag(picks_path, method: :post) do %>
<% @awards.each do |award|…

Travis Smith
- 622
- 5
- 22
1
vote
1 answer
Rails - simple form - adding html options to collection select
I am trying to make sense out of the instructions in this sheet:
http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select
My objective is to make the select menu wider than the default width.
I have…

Mel
- 2,481
- 26
- 113
- 273
1
vote
2 answers
Collection Select not displaying the selected value in edit form for rails 4
I have a Vendor model, a Product model and a VendorProduct model with the following association
class Vendor < ActiveRecord::Base
has_many :vendor_products
has_many :products, through: :vendor_products
end
class Product < ActiveRecord::Base
…

Mahesh Mesta
- 793
- 1
- 11
- 28
1
vote
2 answers
ROR: Collection select with with include_blank won't allow nil
I have a collection select in my form:
<%= f.label :area %>
<%= f.collection_select(:area_id, Area.all, :id, :name, include_blank: "No area.") %>
And my model validation has no requirement for an area.
It was my…

Bevilacqua
- 465
- 3
- 8
- 19
1
vote
1 answer
Rails: Records of two models in one collection_select
Part 1: What i want is to fetch records of two tables in one collection select. Later, i want to perform search based on selected item.
So far i have managed to get the records in this manner in one select:
Controller:
@result1 = Model1.all
@result2…

Aakanksha
- 956
- 1
- 13
- 26