simple-form

Has Many through with simpleform

左心房为你撑大大i 提交于 2019-12-11 20:10:52
问题 I'm struggling to get going with a simpleform field for a hasmany through association. When i submit the form the has_many records are not saved, and if the form doesn't validate the options are not selected when the form redisplays. so in short, nothing is working. I'm not sure how much automagic should be going on here, or if I am just missing code i need to make it work. I don't think it's a strong parameters issue as I am not getting a permit params error in the logs. model class Coupon <

Simple form format a time field to show '21:30' instead of entire UTC time string

时间秒杀一切 提交于 2019-12-11 19:34:11
问题 My rails _form code: <%= simple_form_for @admin_event, :html => { :class => 'main-form' } do |f| %> <%= f.input :time_of_event, :format => l(:time_of_event, '%d %b. %Y'), :as => :string, :label => 'Hora', :input_html => { :class => 'thin', :placeholder => 'eg: 20:30' } %> <% end %> I'm getting the error message: Cannot convert symbol to string. How can I set up this _form to always display this field using a time converter so while the database has a full field ( 2000-01-01 19:30:00.000000 ),

Wrong number of arguments (2 for 4) using simple_form checkboxes

喜夏-厌秋 提交于 2019-12-11 18:59:23
问题 I'm a little confused by the read me for simple_form in regards to a collection of check boxes. Namely, what else am I expected to put on the line besides my options. The readme has :first, :last but doesn't really explain what purpose those words server. Below are two different collections of checkboxes I'd like to have. I should also mention, each checkbox relates to a boolean field in the DB and they are labeled the same as the column names. <%= f.collection_check_boxes :options, [[false,

How to create nested form in Ruby on Rails?

孤街浪徒 提交于 2019-12-11 18:38:00
问题 I have following arragement The Pizza model, to create a list of pizzas that can be ordered by customers, also gets associated with order, so to indicate which pizza has been ordered. class Pizza < ActiveRecord::Base has_many :pizza_orders has_many :orders, :through => :pizza_orders has_and_belongs_to_many :toppings end Option model, to create a list of options that can be associated with certain pizzas, also gets associated with the join table for each pizza order, to specify which pizza has

How do I preserve the `this` from a previous JS state and transfer it to another?

时间秒杀一切 提交于 2019-12-11 18:07:49
问题 So I have a view that has a simple_form, which looks like this: <%= simple_form_for([node, Comment.new], html: { id: "new_comment_card-#{@card_number}"}, remote: true) do |f| %> <%= f.error_notification %> <%= f.input_field :message, as: :text, id: "card-input-field-#{@card_number}", class: "input-field", placeholder: "Share your thoughts", cols: "30", rows: "10" %> <%= f.button :submit %> <% end %> This form appears multiple times on the same view, hence the dynamic id specified. When that

Grouping checkboxes for individual boolean values using css, twitter-bootstrap, and simple_form

落爺英雄遲暮 提交于 2019-12-11 17:51:17
问题 Can you please help me format this simple_form? I am using this form: <%= simple_form_for @my_model, :html => { :class => 'form-horizontal'} do |f| %> <%= f.error_notification %> <div class="form-inputs"> <%= f.input :some_text, :input_html => {:class => "span6", :rows => 2}%> <%= f.input :a_description, :input_html => {:class => "span6", :rows => 2}%> <%= f.input :boolean1%> <%= f.input :boolean2%> <%= f.input :boolean3%> <%= f.input :boolean4%> <%= f.input :boolean5%> <%= f.input :boolean6%

simple_form params ruby on rails; autofill resident variable

▼魔方 西西 提交于 2019-12-11 17:42:37
问题 When a user clicks "add attachment" from resident show page, i'd like to autocomplete the field resident on form. We already know what resident they would like to add the attachment. On the show page button, I pass resident params and these params are visible in the form url. Although the field is not completed. http://localhost:3000/app/attachments/new?resident_id=2 Link on residient show page: <a href="<%= new_app_attachment_path(resident_id: @resident.id) %>" class="btn btn-block btn

Rails + MongoID + Simple Form in association: undefined method `options' for #<Mongoid::Relations::Metadata

僤鯓⒐⒋嵵緔 提交于 2019-12-11 16:27:21
问题 I have the following models which basically refer to Lessons and Categories. Each lesson can have one category, and each category is embedded in a lesson. class Lesson include Mongoid::Document field :title, :type => String field :category, :type => String field :price, :type => Integer field :description, :type => String field :user_id, :type => String validates_presence_of :title validates_presence_of :category validates_presence_of :price validates_presence_of :user_id validates

How to set up a order form with options belonging to a product_category

情到浓时终转凉″ 提交于 2019-12-11 14:46:51
问题 Goal I would like to set up an order form, where users can order one product. After having filled out the product_category, a user can select the product belonging to the product_category the quantity of each option belonging to the product_category. Current state The way I currently set up my code, causes issues when the form has to be built up again: when a validation issue is triggered, (1) product_category, (2) product and (3) options are empty, but also the reservation still saves,

How to remove default input class type from Simple Form, using Rails 4 and Bootstrap 4?

旧城冷巷雨未停 提交于 2019-12-11 10:29:26
问题 I'm using Rails 4.2.4 with Bootstrap 4 (using the bootstrap_ruby gem). Simple Form adds input type classes to the form... if the input is a string it will add a class string to the input. I wanted to know how to stop this from happening? For example, if I had a form with a file input. simple_form_for @attachment do |f| f.input_field :file, as: :file end It will produce the following HTML: <form> ... <div class="form-group file optional photo_image"> <label class="file optional control-label"