formtastic

Adding Numeric Range Filtering to ActiveAdmin

为君一笑 提交于 2019-12-13 15:33:34
问题 Greetings and Happy Holidays 2015 -- I tried to add numeric range filtering per the excellent blog post by Boris Stall. I'm running: Rails 4.2.4 Ruby 2.2.3 ActiveAdmin 1.0.0pre2 I keep running into this error: Unable to find input class NumericRangeInput Here is my config/initializers/active_admin/filter_numeric_range_input.rb module ActiveAdmin module Inputs class FilterNumericRangeInput < ::Formtastic::Inputs::StringInput # Add filter module wrapper include ActiveAdmin::Inputs::Filters:

Formtastic select with grouping

こ雲淡風輕ζ 提交于 2019-12-13 12:04:28
问题 Now with Formtastic I have plain select: = f.input :category, :as => :select, :include_blank => false, :collection => subcategories Here I show only children categories. I use acts_as_tree plugin for parent-child relationship. I would like to show parent categories as well. Formtastic generated select should look like this one: <select name="favoritefood"> <optgroup label="Dairy products"> <option>Cheese</option> <option>Egg</option> </optgroup> <optgroup label="Vegetables"> <option>Cabbage<

How to hide input on conditions in Formtastic?

和自甴很熟 提交于 2019-12-13 00:55:31
问题 I inherited a project that is using ActiveAdmin with Formtastic in Rails. I have very little experience with either of these, but it seems simple enough to do simple tasks. So, I have been tasked with adding a radio input, but hides the another input if the radio doesn't match a certain value. I've search everywhere and can't seem to find anything on this. Here is my form: form do |f| f.inputs 'Book Details' do f.input :name, required: true f.input :has_subtitle, as: radio, required: true f

rails 3, paperclip (& formtastic) - deleting image attachments

一世执手 提交于 2019-12-12 10:59:27
问题 I can't seem to find an example that is complete in all the components. I am having a hard time deleting image attachments Classes class Product has_many :product_images, :dependent => :destroy accepts_nested_attributes_for :product_images end class ProductImage belongs_to :product has_attached_file :image #(etc) end View <%= semantic_form_for [:admin, @product], :html => {:multipart => true} do |f| %> <%= f.inputs "Images" do %> <%= f.semantic_fields_for :product_images do |product_image| %>

Formtastic with Mongoid embedded_in relations

本小妞迷上赌 提交于 2019-12-12 09:22:32
问题 Is there any quick way to make a form for embeds_many-embedded_in relation? I have the following: class Team include Mongoid::Document field :name, :type => String embeds_many :players end class Player include Mongoid::Document embedded_in :team, :inverse_of => :players field :name, :type => String end I want to create a form for team with embedded editing for players. Seen https://github.com/bowsersenior/formtastic_with_mongoid_tutorial but "TODO" there. 回答1: I wrote the formtastic_with

How to loop through two alternating resources on a form?

独自空忆成欢 提交于 2019-12-12 05:26:51
问题 I'm trying to make a dynamic form of questions and answers, like so: Question _ __ _ __ _ Answer _ __ _ __ _ Question _ __ _ __ _ Answer _ __ _ __ _ I can't figure out how to loop through the two resources as alternating pairs. I have tried this: <%= semantic_fields_for [@question, @answer] do |h, i| %> <%= f.inputs :for => @question do |h|%> <%= h.input :question %> <% end %> <%= f.inputs :for => @answer do |i|%> <%= i.input :answer %> <% end %> <% end %> But it gives me the error "Undefined

no implicit conversion of ActiveSupport::SafeBuffer into Integer

天涯浪子 提交于 2019-12-12 04:51:52
问题 Here is my partial _new_post.html.haml : = semantic_form_for Post.new, as: :post, url: client_panel_discussion_posts_path(resource), html: { data: { discussion_posts_url: client_panel_active_submission_discussion_url(resource.client_application, id: resource.slug) }, multipart: true}, builder: ActiveAdmin::FormBuilder, remote: true, method: :post do |f| =f.inputs do =f.input :body =f.has_many :attachments do |a| =a.input :s3_url, as: :hidden, input_html: { class: "s3_url" } =a.s3_file_field

Ruby on Rails + Formtastic: Not checking checkboxes for multiple checked answers

大兔子大兔子 提交于 2019-12-11 18:44:33
问题 EDIT: Solution at bottom and selected answer. I've been working with Formtastic for a while and for the most part like how it simplifies form creation. Unfortunately, I've run into a snag with using checkboxes. For some reason after I save/submit my form, the checkboxes are not getting checked. Code Snippets = ff.input :answer, :as => :check_boxes, :collection => ff.object.survey_question.options, :label => ff.object.survey_question.question -- .options collection method seen below: def

formtastic check_boxes using collection not saving checked items in edit form

倖福魔咒の 提交于 2019-12-11 09:55:09
问题 I know this was supposed to be fixed in Formtastic 2.0 but for some reason, this isn't working for me. <%= f.input :gender, :as => :check_boxes, :collection => ["Male", "Female", "Unisex"] %> Whenever I go back and check it, the items is always unchecked again. It never appears as selected. I know Justin French commented about it here, but I am not sure what it means or how that can help me fix the problem. I am saving gender as a string in the User model if it makes a difference. I am also

Getting Formtastic in ActiveAdmin to use custom form input builder

 ̄綄美尐妖づ 提交于 2019-12-11 02:18:03
问题 UPDATE: So, I've found this, and apparently that's why this old way of doing things isn't working, ActiveAdmin must use Formtastic 2.x. As directed, I've now created a file in app/inputs/date_picker_input.rb that looks like this: class DatePickerInput include Formtastic::Inputs::Base def to_html puts "this is my datepickerinput" end end And my controller now looks like this: f.input :open_date, :as => :date_picker f.input :close_date, :as => :date_picker But now I'm running into this error: