formtastic

Formtastic hint issue (unwanted object ID output) in ActiveAdmin

梦想的初衷 提交于 2019-12-11 01:35:34
问题 When I use formtastic DSL for ActiveAdmin edit form I get the following output: #< #< Class:0x00000006bd1f68>:0x00000006bd1018> <li class="file input optional" id="post_image_input"><label class="label" for="post_image">Image</label><input id="post_image" name="post[image]" type="file" /> Why does this starts from something like result of obj.inspect and how to remove this part? The code, causing this bug is here: form :html => { :multipart => true } do |f| f.inputs do #... f.input :image,

rails formtastic nested form WARNING: Can't mass-assign protected attributes

家住魔仙堡 提交于 2019-12-11 00:23:17
问题 I've following models: class CapstoneMilestone < ActiveRecord::Base attr_accessible :capstone_id, :milestone_id, :rank, :id, :status, :statusweight, :rating, :ratingweight belongs_to :milestone belongs_to :capstone accepts_nested_attributes_for :capstone, :allow_destroy => false accepts_nested_attributes_for :milestone, :allow_destroy => false end class Milestone < ActiveRecord::Base has_many :capstone_milestones has_many :capstones, :through => :capstone_milestones attr_accessible :id, :name

Display the value of a range slider with activeadmin and formtastic

喜夏-厌秋 提交于 2019-12-10 22:56:01
问题 I am using activeadmin with a range field : ActiveAdmin.register Card do form :html => { :enctype => "multipart/form-data" } do |f| f.inputs "Traitements" do f.input :treatment_chlore, :as => :range, :in => 0..10, :step => 0.5 end f.buttons end end I have the slider showing well but i don't see the value of the slider. When we move the slider, i want to see its value on a :hint. How can i do that? 回答1: I needed the same thing -- here's how I ended up solving it (only tested on Chrome. YMMV)

ActiveAdmin “f.inputs, except: [:field]” doesn't work

时间秒杀一切 提交于 2019-12-10 18:30:03
问题 Formtastic has a great tool to prevent certain fields on a model showing up, used as so: f.inputs, :except => [:featured, :something_for_admin_only] ActiveAdmin claims to be derived from Formtastic, but it seems that ":except" doesn't work. Any idea why? 回答1: Try to remove comma ( , ) after f.inputs : f.inputs :except => [:featured, :something_for_admin_only] 来源: https://stackoverflow.com/questions/28943514/activeadmin-f-inputs-except-field-doesnt-work

undefined method `collection_check_boxes'

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 17:56:58
问题 I'm trying to make an invoicing app. The form to create an invoice should include a collection of check boxes so the user can choose which lessons to invoice, but I'm getting this error: undefined method 'collection_check_boxes' . Here are the models involved: class Lesson < ActiveRecord::Base attr_accessible :lesson_time, :lesson_date, :invoice_id belongs_to :invoice end class Invoice < ActiveRecord::Base attr_accessible :amount, :due_date has_many :lessons end And the view: <%= form_for(

Make semantic_errors render the exact error-message

爱⌒轻易说出口 提交于 2019-12-10 15:18:14
问题 I have a model Camping which has_many Images . At least one image is required on Camping: class Camping < ActiveRecord::Base attr_accessible :images_attributes has_many :images validates_presence_of :images, :message => "At least one image is required" accepts_nested_attributes_for :images, :allow_destroy => true end Then, in active_admin, which uses formtastic, I render the error message At least one image is required , with f.semantic_errors : ActiveAdmin.register Camping do form :html => {

Using HABTM or Has_many through with Active Admin

淺唱寂寞╮ 提交于 2019-12-10 09:57:28
问题 I've read quite a few of the posts on using active admin with has_many through association but I'm not getting the desired results. Essentially I have 2 models "Conferences" & "Accounts". I need to assign multiple accounts to a conference and multiple conferences to an account. Wether I use HABTM or has_many through doesn't matter to me. I just need to be able to see a dropdown select option when I create a new conference and vice versa on accounts. Account Model class Account < ActiveRecord:

How do you fix? formtastic :label_method is no longer available

你。 提交于 2019-12-10 03:39:48
问题 Ok.. I'm new to ruby/rails. So to compensate for my weakness, my company had a guy come in to help me create the bones of our website. He put in formtastic :label_method, so we could change what fields are displayed in the DDLB. When I moved my project to a new box, I got this error. :label_method is no longer available What I'm wondering is.. what do I use in it's place? 回答1: I think it might be: :member_label According to http://rubydoc.info/gems/formtastic/2.0.0/Formtastic/Helpers

accepts_nested_attribute_for and multiple edits

亡梦爱人 提交于 2019-12-08 10:39:41
问题 Following on from this answer, I am having a spot of bother with accepts_nested_attributes_for. First things first, this is my error code: undefined method `reflect_on_association' for NilClass:Class line 39 which I get when calling this partial in _formfield.html.haml: 36: = link_to "Edit list", notifications_path 37: %br 38: %li.tip 39: = link_to_add_association 'Add product codes', f, :productcodes 40: = f.semantic_fields_for :productcodes do |productcode| 41: = render 'productcode_fields'

How to use tabs in an ActiveAdmin edit form rendered from an ERB partial

送分小仙女□ 提交于 2019-12-08 05:12:55
问题 I had to change an ActiveAdmin edit form from that I've been using to an ERB partial due to several technical reasons. The form is quite massive and I had to split it into tabs already. When attempting to add tabs by using <% tabs do %> in the ERB partial, the following error appears in the rails server output: Completed 500 Internal Server Error in 209ms ActionView::Template::Error (undefined method `tabs' for #<#<Class:0x007fb1827cdbf8>:0x007fb181b16d60>): 1: <%= semantic_form_for [:admin,