simple-form

File upload field causing ActionController::InvalidAuthenticityToken exception

不羁岁月 提交于 2019-12-03 22:13:30
Using rails 4, and trying to add a file field to an existing form, using simple_form and paperclip. Here's the critical part of the form: <%= simple_form_for(@employee, html: { class: 'form-horizontal requires', multipart: true}, remote: true) do |f| %> <%= f.input :avatar %> <% end %> Everything works ok, unless I actually submit the form with an uploaded file. Then, I get this: ActionController::InvalidAuthenticityToken in EmployeesController#update What am I doing wrong here? The simplest solution would just be to add authenticity_token: true to your form. Like this: <%= form_for @employee,

Rails simple_form server side validations lost URL params

时光怂恿深爱的人放手 提交于 2019-12-03 21:57:04
问题 I'm using simple_form for a form and passing in some URL parameters to prepopulate the form. This code works OK <%= f.input :first_name, :label => 'First Name', :input_html => { :value => params['first'] } %> Using the URL http://localhost:3000/charities/new?first=Bob Which outputs this HTML <input class="string required" id="charity_first_name" name="charity[first_name]" size="50" type="text" value="Bob" /> However if the form server side validation fails the page reloads but the prepopulate

Multiple inputs on a single line with Twitter Bootstrap and Simple Form 2.0

萝らか妹 提交于 2019-12-03 21:49:28
I am using simple_form 2.0 with twitter bootstrap. I am trying to determine what is the proper wrapper format in order to get something like [city] [State] [Zip] I believe my form needs to be <div class="control-group"> <%= f.input :city,:wrapper => :small, :placeholder => "City", :input_html => { :class=>"span2", :maxlength => 10},:label => false %> <%= f.input :region, :wrapper => :small , :placeholder => "Region", :input_html => { :class=>"span1", :maxlength => 5}, :label => false %> <%= f.input :postal_code, :wrapper => :small, :placeholder => "Postal Code",:input_html => { :class=>"span2"

Simple Form Error Notification

◇◆丶佛笑我妖孽 提交于 2019-12-03 17:14:46
I am trying to figure out how to use Simple Form with Rails, Devise, Omniauth and Bootstrap. I have several problems, but one of them is error notifications. I have a devise sign in and sign up form inside Bootstrap modals. The registration form is as follows. Note that I removed the required: true function from the form because I don't like the asterisk being appended to the label (but I did try putting it back to see if the error notifications would work). <% if user_signed_in? %> <li> <%= link_to('Edit registration', edit_user_registration_path) %> </li> <% else %> <li> <%= link_to

Rails simple_form association

泄露秘密 提交于 2019-12-03 16:20:08
I'm trying to create a form for 'Member' using simple_form and having trouble displaying an association where it display the organization as below instead of the id, or organization_name. Am I missing something here? How should I go about this? **Organization:0x0000000485cf88 Organization:0x0000000485c948 Organization:0x0000000485c358** class Organization < ActiveRecord::Base has_many :members attr_accessible :organization_name end class Member < ActiveRecord::Base belongs_to :organization attr_accessible :active, :email, :first_name, :last_name, :role end <%= f.input :first_name %> <%= f

Simple_form class form-horizontal with bootstrap 3 not working in rails 4

妖精的绣舞 提交于 2019-12-03 14:53:13
I have two rails apps, and the 'form-horizontal' is working in one, but not the other, and I have no idea why. First app is called "Horizontal" (my test app) and the other is "Inventory" Form in "horizontal" app: <%= simple_form_for(@part, html: {class: 'form-horizontal' }) do |f| %> <div class="field"> <%= f.input :name %> </div> <div class="field"> <%= f.input :number %> </div> <div class="actions"> <%= f.submit %> </div> <% end %> and looks like this in the browser: and the form for the "inventory" app is: <%= simple_form_for(@item, html: {class: 'form-horizontal' }) do |f| %> <%= f.error

simple_form collection wrapper (radios buttons) : double encapsulation of items

纵然是瞬间 提交于 2019-12-03 13:11:46
I'd like to reproduce this html sequence of radio buttons with simple_form in order to make simple_form work with http://semantic-ui.com/ syntax : <div class="grouped inline fields"> <div class="field"> <div class="ui radio checkbox"> <input type="radio" name="fruit" checked=""> <label>Apples</label> </div> </div> <div class="field"> <div class="ui radio checkbox"> <input type="radio" name="fruit"> <label>Oranges</label> </div> </div> <div class="field"> <div class="ui radio checkbox"> <input type="radio" name="fruit"> <label>Pears</label> </div> </div> <div class="field"> <div class="ui radio

Rails 4 simple_form has_many through check boxes not saving

半腔热情 提交于 2019-12-03 13:05:50
问题 I am trying to implement an employee recurrent deductions table through check boxes using simple_form. My code works but the selected recurrent deductions are not saved in my table. I can't work out why. Here are my models. class Employee < ActiveRecord::Base belongs_to :club has_many :employee_recurrents has_many :recurrents, :through => :employee_recurrents end class Recurrent < ActiveRecord::Base belongs_to :club has_many :employee_recurrents has_many :employees, :through => :employee

Creating inline date_select dropdowns using simple_form and zurb foundation

大憨熊 提交于 2019-12-03 12:35:25
I'm using Simple_Form with Zurb Foundation in my rails application. One of more views has a form with the following date_select The form fields are showing up stacked rather than inline. I've checked everything and can't figure out how to get these to show-up correctly. What am I missing? You can see the repo at https://github.com/stanrails/momtomom in the event.html.erb view. The code for the section is below: <div class="row"> <div class="small-5 columns"> <%= f.date_select :eventDate %> </div> </div> One of the workaround is to have something manually like this: form.custom .dropdown.date{

simple_forms custom data attribute

ⅰ亾dé卋堺 提交于 2019-12-03 10:34:34
问题 I would like to have an additional data attribute on an input tag generated by simple_form. The following does not work: <%= f.input :date, :as => 'date_picker', :data => {:datepicker => :datepicker} %> How could this be done? Is it possible at all? As you might have guessed: I am trying to add bootstrap-datepicker to my site without using explicit js to initialize the date picker. 回答1: The correct API is: f.input :date, :as => 'date_picker', :input_html => { :data => {:datepicker =>