formtastic

rails ActiveAdmin nested form has_one accepts_attributes_for formtastic issue

↘锁芯ラ 提交于 2019-11-30 06:31:00
问题 I am using ActiveAdmin and Rails 3.1 -- having problem understanding whether the following is a bug, or if there is some way to do it correctly that I am not understanding. I am trying to use a nested model with a has one relationship, so that I can create a page and fill out it's meta data in 1 step. -- (page has_one meta_data, accepts_nested_attributes_for meta_data) Example 1) in this example, when I click new page, meta data section is there but there are no input fields -- also, if I

Formastic Bootstrap Rails Error- No Such File to Load ButtonsHelpers

跟風遠走 提交于 2019-11-30 05:00:12
问题 I'm completely stuck on this error. Using Rails 3.1 trying to implement Formastic Bootstrap gem and getting error: `': no such file to load -- formtastic/helpers/buttons_helper (LoadError) Application.css *= require formtastic *= require formtastic-bootstrap Gemfile group :assets do gem 'sass-rails', " ~> 3.1.0" gem 'coffee-rails', "~> 3.1.0" gem 'uglifier' gem 'less-rails-bootstrap' gem 'bootstrap-sass' end formastic.rb Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap:

How to display only the value in edit page in Active Admin

萝らか妹 提交于 2019-11-30 04:34:49
I have a edit form in Active Admin. I need some field as read only. My current edit page is like I need the page look like this How can this be done. My code for the edit form page is like form :html => { :enctype => "multipart/form-data" } do |f| f.inputs "Users" do f.input :device, :label => 'Device', :as => :select, :collection => DEVICE, :include_blank => false f.input :current_address, :label => 'Current Address', :as => :string end end Please help. Will As Alex said, set to disabled. You could then use css to get the visual you wanted, if you can live with the semantics of that. The

formtastic - how to prepopulate a string input with a value

非 Y 不嫁゛ 提交于 2019-11-30 02:53:43
I'm building an app, where users can give comments by just leaving their email to the comment. I want them to be able to register directly from there, by a link with their email adress as a param (like: <%= link_to register_path(:email => @comment.email %> ) - so there is no existing user record yet. this should be done by applying a value to the form.input field via the :value option. But the following code doesn't work! <%- if params[:email] -%> <%= f.input :email, :required => true, :value => params[:email] %> <%- else -%> <%= f.input :email, :required => true %> <%- end -%> I had a look

ActiveAdmin with has_many problem; undefined method 'new_record?'

喜夏-厌秋 提交于 2019-11-29 23:25:58
I'm trying to customise a ActiveAdmin form for a Recipe model that has a has_many relationship with Step. class Recipe < ActiveRecord::Base has_many :steps end class Step < ActiveRecord::Base acts_as_list :scope => :recipe belongs_to :recipe end I have the following in my ActiveAdmin file with relation to this: form do |f| f.has_many :steps do |ing_f| ing_f.inputs end end The following error is thrown when I try to load the form: undefined method `new_record?' for nil:NilClass I've isolated it so far to the has_many method but I'm lost past this. Any advice and help would be appreciated! Dan

Multi-step form in Rails 3 with Paperclip attachments

元气小坏坏 提交于 2019-11-29 13:49:53
I'm creating a multi-part form in the style that Ryan Bates describes here: http://railscasts.com/episodes/217-multistep-forms http://asciicasts.com/episodes/217-multistep-forms (text-based version) To summarize, I have one view (with a bunch of partials for each form step), and the form variables are stored in a session when the user clicks a next button and a different part of the form is displayed. One of my form steps allows the user to upload several images via the Paperclip gem. The problem with that is that Rails is trying to upload the image data to the session, which is returning

how to embed raw html in active_admin formtastic

送分小仙女□ 提交于 2019-11-29 07:48:56
I'm trying to build a form, with formtastic, inside an active_admin model. The problem is I need a certain script tag and other raw HTML stuff directly inside or around the form. I'm doing it with the normal form block: form do |f| f.inputs :name => "User Details", :for => :user do |user_form| user_form.input :first_name, :required => true ... How do I embed a simple div tag right in between? Or even a script tag? I thought about using a render :partial , but I want to know if the above method is possible first. Thanks! You can insert a div or javascript like this: f.form_buffers.last <<

How to display only the value in edit page in Active Admin

余生颓废 提交于 2019-11-29 02:26:11
问题 I have a edit form in Active Admin. I need some field as read only. My current edit page is like I need the page look like this How can this be done. My code for the edit form page is like form :html => { :enctype => "multipart/form-data" } do |f| f.inputs "Users" do f.input :device, :label => 'Device', :as => :select, :collection => DEVICE, :include_blank => false f.input :current_address, :label => 'Current Address', :as => :string end end Please help. 回答1: As Alex said, set to disabled.

Activeadmin formtastic dynamic select

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 02:08:40
I would like to make a dynamic select option via Activeadmin 's formtastic like so: form do |f| f.inputs "Exam Registration Details" do f.input :user_id, :as => :select, :collection => User.where(:admin => 'false') #selects user from list. WORKING f.input :student_id, :as => :select, :collection => Student.joins(lessons: :user) #collection of students will change to students who have lessons with chosen user. NOT WORKING, returns all students who have lessons. f.input :lesson_id, :as => :select, :collection => Lesson.joins(:student, :user) #collection of lessons will change to reflect lessons

how to change class of a label for checkboxes in simple_form

和自甴很熟 提交于 2019-11-28 21:07:34
using simple_form we can change class of a label using: label_html => {:class => "myclass"} but how do we do the same when dealing with checkboxes? simple_form assigns the default class of collection_check_boxes Is there a way to change this default class? I wanted to give an update to this answer in case someone comes here looking for a way to do this as I did. You can give the label a class with this option :item_wrapper_class => 'class_goes_here' Here is a full example: = user.input :resident, :collection => [["In the U.S", true],["Outside the U.S.", false]], :label_method => :first, :value