Questions tagged [collection-select]

143 questions
1
vote
1 answer

Rails 4, Collection Select, and Select2 Plugin: Populated Dropdown Appears over Textfield

So I have quite a long list of properties (2000+) and when I click the text field "Select Affected Properties..." the dropdown appears with the correctly populated data. This is good. Now, why in the world is the populated dropdown hovering over…
Nubtacular
  • 1,367
  • 2
  • 18
  • 38
1
vote
1 answer

Rails: $/hour - only save part of a collection select for a monetary field

In my Rails form I have a field for selecting a person's rate/hour. I would like this to display in my form as a collection_select dropdown with select options of the format: $1.00 per hour $1.25 per hour $1.50 per hour etc. Currently I have a rate…
Brett
  • 162
  • 13
1
vote
2 answers

Rails 5 collection_select: Showing multiple attributes in one column

I'm trying to make a collection select which shows two attributes from two different models. I want to select an account. The account has a name and an owner. The owner is a model which also has the attribute name. When using the collection select…
Hak
  • 13
  • 4
1
vote
2 answers

Disable only first option of collection_select in Rails

<%= f.collection_select :admin_attachment_id, @data['attachments'], :id, :title, { prompt: 'Select banner' }, { class: 'form-control', required: '', 'ng-model': 'banner.admin_attachment_id', 'ng-change': 'get_attachment_thumbnail()', disabled:…
developer033
  • 24,267
  • 8
  • 82
  • 108
1
vote
1 answer

Ruby on rails collection_select. Multiple and remote not working together

Ok, I have a multi select box controlled by chosen jquery plugin. I can get multi select working without ajax, and ajax working without multiselect, but not the two together. Here multi select works, but reloads the whole page when an item is…
Rob Hughes
  • 876
  • 2
  • 13
  • 32
1
vote
3 answers

No route matches in Rails code

This code is all based on the Ruby on Rails tutorial by Michael Hartl. I created an assigned action in my users_controller with def assign puts "in assign..." @scout = User.find(params[:follower_id]) @der =…
mjswartz
  • 715
  • 1
  • 6
  • 19
1
vote
1 answer

Load data on "select_tag" select

I have standard e-commerce models: ProductCategory, Product, Order and OrderItem In OrderItem model there is product_id column. When user create an order and add a new order item, I want to let him first choose product category (in select_tag) and…
Peter Tretyakov
  • 3,380
  • 6
  • 38
  • 54
1
vote
0 answers

Rails 4: Collection_Select does not save state after failed validation

I have a collection select method as shown: <%= fields_for :deal_venue do |dv| %>
<%= dv.label "Select Venues" %>
<%= collection_select(:venues, :id, @all_venues, :id, :name, {},…
user5296896
  • 179
  • 1
  • 13
1
vote
1 answer

Ruby on Rails multiple collection_select

I have a User model that belongs to a University and a Faculty and a Department. A University has many Faculties. A Faculty has many Departments. In my user creation form (using devise), What is the best way to have 3 drop down lists that change…
1
vote
2 answers

Rails - collection_select - populate with the values listed in a model

I have a model defined like that: class Order < ActiveRecord::Base belongs_to :user TYPES = %w[t_01 t_02 t_03] validates :order_type, inclusion: { in: TYPES } end I am trying to make a dropdown menu in the view that will be populated by…
Michal
  • 139
  • 3
  • 14
1
vote
1 answer

Id not saved when submitted through collection_select in nested form

I am working on a program that calculates rations. Each ration has ration_items, that consist of a feedstuff and a quantity. class RationItem < ActiveRecord::Base belongs_to :feedstuff belongs_to :ration validates :name, presence: true …
kees
  • 13
  • 4
1
vote
1 answer

Wrong number of Arguments error in collection_select

I have a form ; <%= form_for @boats do |f| %> <%= f.collection_select(:brand, :brand_id, @brands, :id, :name, {:prompt => "Select a Brand"}, {:id => 'brands_select'}) %> <%= f.collection_select(:year, :year_id, @years, :id, :name, {:prompt …
Shalafister
  • 401
  • 2
  • 6
  • 21
1
vote
3 answers

Set Hidden Field Value Based on Collection_select select menu

I am using select2 and I have a collection_select in an update form that looks like this: <%= collection_select(:event, :project_date_id, @project_dates.available, :id, :schedule_date, :prompt => false, :selected => @set_date.id) %> When an option…
1
vote
1 answer

Rails collection_select how to reference hash correctly?

As you can see below I have created a hash but I don't know to to reference that hash in my collection_select tag. So I already did this successfully but my hash was a collection of profile objects, when I try to do it with a collection of key value…
MetaStack
  • 3,266
  • 4
  • 30
  • 67
1
vote
1 answer

Collection Select undefined method in Rails 4

I have a form that requires pulling all of the objects in the database into a select field. I've reviewed other SO questions about collection_select and can't seem to figure out why I'm getting an undefined method error. # Loan Application…