simple-form

How to list all countries in select using country_select gem with simple_form

烂漫一生 提交于 2019-12-07 07:57:14
问题 I have added gem 'country-select' to my gemfile, and I need to list all countries in a select. I try <%= f.input :country, as: :select %> but countries don't appear. There are no info about that in documentation. Please help me with this issue. 回答1: try this out <%= f.input :country, as: :country %> 来源: https://stackoverflow.com/questions/18302078/how-to-list-all-countries-in-select-using-country-select-gem-with-simple-form

Is it possible to use a scope as source for association with simple_form?

我的未来我决定 提交于 2019-12-07 03:57:26
Is it possible to use a scope as source for association? class User < AR scope :active_users, where('status = 4') ... # form <%= f.association :active_users %> ... Sorry, I don't think that will work. A scope returns an ActiveRecord::Relation and simple_form is looking for a symbol that represents an existing ActiveRecord::Association (E.g. has_many, belongs_to). https://github.com/plataformatec/simple_form#associations You can use collection for source in controller @active_users = User.active_users in view <%= f.association :active_user, collection: @active_users %> 来源: https://stackoverflow

Adding controls inline with simple_form, nested_form and Twitter Bootstrap in Rails

我与影子孤独终老i 提交于 2019-12-07 02:56:27
问题 I'm using simple_form, nested_form and Twitter Bootstrap and trying to put the "Remove Link" from nested_form on the same line as the object. Right now it looks like this: http://grab.by/eKDS and I want it to look like this: http://grab.by/eKEc Here's what my code looks like: <%= cform.simple_fields_for :licensings do |lf| %> <%= lf.input :state, :collection => us_states, :wrapper => false %> <%= lf.link_to_remove "Remove this Licensing", :class => 'btn btn-mini btn-danger' %> <% end %> I've

Testing HTML 5 form validations when using simple_form Rails

落爺英雄遲暮 提交于 2019-12-07 02:23:00
问题 I'm using devise and simple_form for my todo list app . Now , I have the following code for my users/edit.html.erb <%= content_for :title,'Edit profile' %> <h2>Edit profile</h2> <%= simple_form_for current_user, class: 'form-horizontal' do |f| %> <%= f.input :nick_name %> <%= f.submit 'Update profile' %> <% end %> My user.rb looks like this : class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable attr_accessible

Simple form radio button

不打扰是莪最后的温柔 提交于 2019-12-07 01:35:43
问题 i'm using the simple_form gem and really like its simplicity. However, trying to set to set up a simple radio button is beyond me as I keep getting the following error "undefined local variable or method `vegan'" 1.Here what I have so far <%= f.collection_radio_buttons :diettype, [[vegan, 'vegan'] ,[vegetarian, 'vegetarian']]%> 2.Heres the code I used before simple_form with an update/patch method, which would update and save a users requirement <%= f.label(:diettype, "Vegan") %> <%= f.radio

rails: a single simple_form with two unrelated models?

喜你入骨 提交于 2019-12-06 15:16:03
问题 I want to use simple_form_for to display a form that contains inputs for creating an instance of model A and separately an instance of model B. I want to have a single submit button for the form. Models A and B are not associated in any way, so simple_fields_for doesn't seem to apply here. Ideally, params would contain two hashes, under the keys A and B, so that each object's fields are grouped together. Is there a way to achieve this using simple_form? Thanks. 回答1: You could use fields_for

simple_form and hstore basic functionality

筅森魡賤 提交于 2019-12-06 13:32:00
I can get hstore to work with simple_form but all but the most basic functionality (saving) just doesn't work. Validation messages don't show up on the individual fields... all hstore fields oddly show as required, even the values themselves don't populate correctly unless set manually. I have to do something like this: <%= f.simple_fields_for :phones do |phone| %> <%= phone.input :agent, :input_html => { :value => @artist.phones['agent'] } %> <% end %> I have to use simple_fields_for for the hstore hash and it saves properly but on edit the values don't populate without using the input_html

ruby-on-rails client_side_validation simple_form javascript error

二次信任 提交于 2019-12-06 09:14:37
Ruby on Rails application and trying to add client_side_validation working and getting two javascript runtime errors when visiting the screen fields. The errors; Uncaught TypeError: Cannot call method 'add' of undefined Uncaught TypeError: Cannot call method 'remove' of undefined The Gemfile source 'https://rubygems.org' ........ gem 'simple_form' gem 'client_side_validations' gem 'client_side_validations-simple_form' ..... The application.html.erb <!DOCTYPE html> <html> <head> <title><%= content_for?(:title) ? yield(:title) : "Drill Investor" %></title> <!--[if lt IE 9]><script src="http:/

Make all input fields on the same line

无人久伴 提交于 2019-12-06 09:12:20
问题 Im trying to use css to make all the fields for my form display on one line. It's part of the header nav on my page so it is important that it shows on one line instead of multiple lines. Here's my header code at the moment. <div class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-target=".nav-collapse" data-toggle="collapse"> <span class="i-bar"></span> <span class="i-bar"></span> <span class="i-bar"></span> </a> <a class="brand"

simple_form: specify id of text field

时光总嘲笑我的痴心妄想 提交于 2019-12-06 06:09:13
问题 I've got the simple simple_form below. I'm trying to make the ID of the input field be 'my-id', but the solution below doesn't work (the id is 'comment_body'). How can I specify the id for that input field? = simple_form_for(@comment) do |f| = f.input :body, as: :string, html: {id: "my-id"} = f.button :submit I've also tried = f.input :body, as: :string, id: "my-id" to no avail. 回答1: :input_html works, not :html . = f.input :body, as: :string, input_html: {id: "my-id"} 回答2: The way to add an