collection-select

Rails: Multiple dropdown menus collection_select

橙三吉。 提交于 2021-02-17 05:05:32
问题 Super Rails n00b here: Currently I have a form with the following code: <%= f.collection_select :account_ids, @accounts, :id, :name, include_blank: true %> and it currently works how I want it to but now I would like to have multiple drop down menus so I can select multiple accounts. I do not want the multiple select to be on the same dropdown. If I do this: <%= f.collection_select :account_ids, @accounts, :id, :name, include_blank: true %> <%= f.collection_select :account_ids, @accounts, :id

has_many :through and collection_select rails form

删除回忆录丶 提交于 2021-01-27 20:25:53
问题 I have tried all of the solutions to similar problems and haven't gotten this one figured out. I have a has_many :through relationship between 'Clinician', and 'Patient' with a joined model 'CareGroupAssignment'. None of the methods I have tried so far been able to save the clinician to patient association. I would like to have a patient be able to have multiple clinicians associated with it and clinicians will have multiple patients . clinician.rb (simplified) class Clinician < ActiveRecord:

Option from collection_select creates a new one on submit - Rails 5

痞子三分冷 提交于 2020-01-16 17:10:05
问题 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 submit the form, a new Category is created. For example I select the category Synthesizer. When I submit, I suddenly have two categories called Synthesizer. How can I make it so that the Plugin is associated with the Category, but does not create a

use an image for radio button label rails 4

我只是一个虾纸丫 提交于 2019-12-22 10:52:40
问题 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 label Something i have noticed already is that i can only click the radio button once and it then just stays in its on state <%= f.collection_radio_buttons(:default_image_id, DefaultImage.all, :id, :image) %> The html generated looks like so <input id=

Rails 5 - use collection_radio_buttons to open a partial with nested models?

做~自己de王妃 提交于 2019-12-13 20:28:33
问题 (my first SO question, so please be kind!) Each Schedule has only one System; Each System has many Applications; Each Application has many Users and Documents. What I want to do to create a Schedule entry: Generate a form that first shows multiple System names that can be clicked. When a System is clicked, it opens a partial that lists Applications associated with that System. Then, when clicking particular Applications, yet another partial opens that contains Users and Documents associated

UJS, AJAX, Rails 4, form_for collection_select to pass value into method and return value back to form

≡放荡痞女 提交于 2019-12-13 16:25:03
问题 I'm very new to Rails, and as such am having lots of of confusion when dealing with AJAX, UJS and Rails together. I've looked at railscast, several SO answers, tried #rubyonrails IRC channel on freenode. Alas, I'm still stuck. Anyway, here is my problem. SO I have two Models, Building and Property. Property belongs_to Building and Building has_many Properties. I've added the foreign key to Property as building_id. Now, in my building model, I have a Method: self.search(search) and given the

RoR: How to set the value in a collection_select from the database in the edit view (1:many relation)

不打扰是莪最后的温柔 提交于 2019-12-12 06:09:38
问题 I am at the moment creating a complicated rails form for 1:n relationship with nested form and collection select with values from yet another data table. So far, it overwrites the database value with the first entry in the values list of the collection_select whenever the user does not select the correct value before update. I still need to set the initial value in the collection_select correctly. I have read a lot of questions on SO already, most relevant was: f-collection-select-not

Collection_select not saving

流过昼夜 提交于 2019-12-12 05:15:56
问题 I'm trying to implement a collection select to create associations between my model group and user (join table: groups_user). But this association is not saving when i'm using a collection_select. And I have absolutely no idea what can be the problem My code : view : <%= simple_form_for(group, remote: true) do |f| %> <%= f.collection_select :user_ids, @users.order(:pseudo), :id, :pseudo, {}, {multiple: true} %> <%= f.submit %> <% end %> & my controller(group) : def group_params params.require

Select 2 in Rails not rendering properly

六月ゝ 毕业季﹏ 提交于 2019-12-12 03:55:17
问题 I am trying to implement select2 functionality in my project. It is not rendering properly. I am pasting my code, please tell me where it went wrong <div class="form-group"> <label for="userInputCollegeName">College Name</label> <%= f.collection_select(:college_id, College.all, :id, :name, {:prompt => 'Select the college'}) %> </div> <script>$(document).ready(function() { $("#user_college_id").select2({theme: "bootstrap"}); });</script> In my html the id for the collection_select is user

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

我们两清 提交于 2019-12-11 12:13:25
问题 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 values available in TYPES. The one shown below is of course not the right one, because it populates dropdown menu with types that belong to orders already recorded in DB: <div class="field"> <%= f.label :order_type %><br> <%= f.collection_select :order_type,