simple-form

remote simple_form_for with re-defined method

孤街醉人 提交于 2019-12-11 10:23:28
问题 Cheers! = simple_form_for :search_input, :url => 'tracks/result', :method => :get do |f| How to make this form :remote => true correctly? 回答1: Like this: = simple_form_for(:search_input, :url => 'tracks/result', :method => :get, :remote => true) do |f| 来源: https://stackoverflow.com/questions/13732004/remote-simple-form-for-with-re-defined-method

Rails Simple_Form: How to show long name of the country

冷暖自知 提交于 2019-12-11 08:11:43
问题 I use simple_form gem to select country: = simple_form_for @shop, :url => { :action => "create" }, :html => {:id => 'new_shop' } do |f| = f.simple_fields_for :address, :html => {:multipart => true} do |o| = o.input :country, :label => "Country" But the name of the country is being saved in short format in the database (like RU , FR , AU , and so on). I wonder, how can I show the full, long name of the country in the views? Thanks! 回答1: Actually is a good idea saving the country code in the

Nested form error in Rails app

混江龙づ霸主 提交于 2019-12-11 05:11:34
问题 Models relevant to this question: user, friend, interest, person_interest. Person_interest is polymoprhic and can store interests that either belong to a user or a friend. Interests is pre-populated with approx. 30 interests. When a user registers they are asked to select their own interests, then lower in the form enter in their friends names select the interests of that person. Trying to achieve this with <%= friend_f.input :interests, :as => :check_boxes, :label => false %> but getting the

Using Arrays in Simple_form

随声附和 提交于 2019-12-11 03:39:28
问题 Using Rails 4.1.5 and simple_form, 3.0.2 and Postgresql, I have declared an array, rsvp_options in the functions table. Following stAndres answer, I did the following <%= simple_form_for @function do |f| %> <%= f.input_field :rsvp_options, multiple: true %> <%= f.input_field :rsvp_options, multiple: true %> <%= f.button :submit , class: 'btn btn-primary'%> <% end %> If @function.rsvp_options is initalised with ['test1','test2'], then simple form displays two boxes, but both ones have {'test1'

Complex Form Nesting in Rails - How to create the desired hash / array params output

别来无恙 提交于 2019-12-11 03:03:21
问题 I'm trying to figure out how to properly handle the params hash so as I dont pass params that should be nested multiple times.. Here is a simplified(removed not-needed info like labels etc) of my html.slim code (using simple_form): = f.simple_fields_for :room do |r| - (1..4).each do |room| = r.input 'adults',:collection => 1..4,:input_html => {:name => "room[adults][]"} = r.input 'children',:collection => 0..2,:input_html => {:name => "room[children][]"} - (1..2).each do |child| = r.input

rails 4 simple_form belongs_to association undefined method error

无人久伴 提交于 2019-12-11 02:25:12
问题 Using rails 4, when I want to render a form (with simple_form) from an object Document::Document I have this error: undefined method document_type_id for #<Document::Document:0x007fada4a50240> Here a part of my model: class Document::Document < ActiveRecord::Base ... belongs_to :document_type, -> {include(:translations)}, :class_name => 'Document::Type' ... end The method new of my controller: def new @document = Document::Document.new end And a part of the form with simple_form: =f

Remove outer label from collection_check_boxes

﹥>﹥吖頭↗ 提交于 2019-12-10 18:27:12
问题 I am generating a table from my association checkboxes. Each row shows a checkbox and some additional information. %table = f.collection_check_boxes :task_ids, @my_collection, :id, :label do |r| %tr %td= r.label %td= r.check_box %td= r.object.due_date But this breaks my HTML since the output looks like this: <table> <span><label for="task_ids_1"> <--- I want to remove this... <tr> <td><label for="task_ids_1">My Name</label></td> <td><input type="checkbox" value="8" name="user[task_ids][]" id=

Remove datetime and time separator in date select with simple form rails

你。 提交于 2019-12-10 16:59:33
问题 How I can remove datetime separator and time separator in date select create by gem called simple_form ? I think I must override initialize method that simple_form use to create date select or pass hash options in input of my form. But it doesn't work. I try something like this : f.input :as => :date, options:{:date_separator => '', :time_separator => ''} Thanks to help me 回答1: You have to make this change to make it work: f.input :your_attribute, as: :date, date_separator: '', time_separator

accept_nested_attributes_for :allow_destroy, :_destroy not working

一世执手 提交于 2019-12-10 16:11:31
问题 I have a Rails 4.1 application which is using a few notable technologies. Simple Form, Cocoon I'm having trouble destroying records which are nested attributes. Based on some lengthy research, I believe my code is correct, however I may be missing something silly. Model has_many :staff_services_joins, :dependent => :destroy has_many :services, :through => :staff_services_joins accepts_nested_attributes_for :staff_services_joins, :allow_destroy => true It's a little unorthodox, but I have two

How can I set timezone in simple form datetime field?

亡梦爱人 提交于 2019-12-10 14:58:52
问题 I have a model with a datetime field, and is stored in UTC, how can I display that date in simple form gem in a specific timezone? Already tried with the option input_html: {value: @model.date.in_time_zone('Eastern Time (US & Canada)')} Note: I can't change the timezone of rails app 回答1: It will work if you set the timezone in the controller: Example: around_action :set_time_zone, if: :current_user private def set_time_zone(&block) Time.use_zone(current_user.time_zone, &block) end 来源: https:/