simple-form

simple_form_for rails radio button inline

孤街浪徒 提交于 2019-12-02 16:19:55
I am trying to get my buttons to display inline and also have a default value because it can't be blank. I am usingplataformatex/simple_form and bootstrap. = f.collection_radio_buttons :is_private, [[true, 'Private'], [false, 'Public']], :first, :last, style: "display:inline", default: true It is rendering this: <span> <input id="workout_is_private_true" name="workout[is_private]" type="radio" value="true" /> <label class="collection_radio_buttons" for="workout_is_private_true">Private</label> </span> <span> <input id="workout_is_private_false" name="workout[is_private]" type="radio" value=

Rails4: Formtastic3.0 , save multiple instances (for Answer models) at the same time

狂风中的少年 提交于 2019-12-02 15:13:30
问题 I have Question model and an answer model. Each question can have one answer per user. I am trying to preset to a user a form to answer all questions, but couldnt really figure out how to do it with formtastic Here is what I have so far - @questions.each do |q| = q.content - ans = @user.answers.where(question_id:q.id).first.try(:content) || q.description = semantic_form_for @answers do |f| = f.label q.content = f.inputs :content, placeholder: ans = f.actions I am trying to get some hint from

Customize Route to New User Registration Page in Devise Simple_Form_For Posting new form to Devise Registration Controller

ぐ巨炮叔叔 提交于 2019-12-02 10:52:40
an idea - should I be making a new controller that inherits the registrations controller? and then do another devise_for :users, :controllers => {:registration => "newcontroller"} change my trial_signup.html.erb to new.html.erb and make a new folder in app/views/devise/registrations2/new.html.erb Newest Update app/views/devise/trial_signup.html.erb <h2>Trial Sign up</h2> <%= simple_form_for(resource, :as => resource_name, :url => sales_path(resource_name)) do |f| %> <div class="row"> <div class="col-xs-6 col-md-6"> <%= f.input :first_name, :autofocus => true, :input_html => { :class => "form

Rails4: Formtastic3.0 , save multiple instances (for Answer models) at the same time

折月煮酒 提交于 2019-12-02 10:26:21
I have Question model and an answer model. Each question can have one answer per user. I am trying to preset to a user a form to answer all questions, but couldnt really figure out how to do it with formtastic Here is what I have so far - @questions.each do |q| = q.content - ans = @user.answers.where(question_id:q.id).first.try(:content) || q.description = semantic_form_for @answers do |f| = f.label q.content = f.inputs :content, placeholder: ans = f.actions I am trying to get some hint from How to loop through two alternating resources on a form? but I keep getting "undefined method `model

Nested attributes - Unpermitted parameters Rails 4

老子叫甜甜 提交于 2019-12-02 10:25:16
问题 There is a lot of resources on SO about issues on Nested attributes in Rails 4 regarding strong parameters but I don't find any solution on this: (so sorry if it's a duplicate) I have a 1-1 relation between member and profile. When trying to update a member with profile attributes I've got this error: Unpermitted parameters: profile Where are my params ===> params: {"member"=>{"profile"=>{"first_name"=>"test", "last_name"=>"test"}, "email"=>"test@test.com"}} My models: Member.rb class Member

undefined method merge_wrapper_options

我只是一个虾纸丫 提交于 2019-12-02 03:49:35
问题 I am trying to use a fake input for Simple form as documented here: https://github.com/plataformatec/simple_form/wiki/Create-a-fake-input-that-does-NOT-read-attributes. f.input :address, as: :fake However, I get an error "undefined method `merge_wrapper_options' for #". I get this error even after restarting the rails server. Please help me solve this. Thanks. 回答1: Summary The instance method merge_wrapper_options is defined on the SimpleForm::Inputs::Base class, but not until version 3.1.0

undefined method merge_wrapper_options

折月煮酒 提交于 2019-12-02 03:16:27
I am trying to use a fake input for Simple form as documented here: https://github.com/plataformatec/simple_form/wiki/Create-a-fake-input-that-does-NOT-read-attributes . f.input :address, as: :fake However, I get an error "undefined method `merge_wrapper_options' for #". I get this error even after restarting the rails server. Please help me solve this. Thanks. Summary The instance method merge_wrapper_options is defined on the SimpleForm::Inputs::Base class, but not until version 3.1.0.rc1. Here's the relevant source code for version 3.0.2 (no merge_wrapper_options ): https://github.com

No errors and no output for rails cocoon gem

喜夏-厌秋 提交于 2019-12-02 02:18:36
I am working on a dynamically nested form using the cocoon gem. I have two models class CrossTable < ActiveRecord::Base attr_accessible :title, :table_name, :database, :folder_label_id, :foreign_fields_attributes belongs_to :folder_label has_many :foreign_fields accepts_nested_attributes_for :foreign_fields validates :title, :table_name, :database, :folder_label_id, presence: true end class ForeignField < ActiveRecord::Base attr_accessible :cross_table_id, :column_name, :description belongs_to :cross_table has_many :filter_sets end I have cocoon and jquery-rails in the gemfile I added //

SimpleForm default input class

◇◆丶佛笑我妖孽 提交于 2019-12-01 19:38:30
I'm using SimpleForm + Bootstrap. How can I add an attribute to all type="text" inputs with class = span12 ? Something that outputs something like this: <div class="controls"><input autofocus="autofocus" class="string required span12" id="user_first_name" name="user[first_name]" required="required" size="50" type="text" value=""></div> I tried playing with config.wrappers but this ba.use :input, :wrap_with => { :class => 'span12' } doesn't work. It adds to wrapper instead of modifying the input tag. Any thoughts? SimpleForm.setup do |config| config.wrappers :bootstrap, :tag => 'div', :class =>

SimpleForm default input class

落花浮王杯 提交于 2019-12-01 19:22:26
问题 I'm using SimpleForm + Bootstrap. How can I add an attribute to all type="text" inputs with class = span12 ? Something that outputs something like this: <div class="controls"><input autofocus="autofocus" class="string required span12" id="user_first_name" name="user[first_name]" required="required" size="50" type="text" value=""></div> I tried playing with config.wrappers but this ba.use :input, :wrap_with => { :class => 'span12' } doesn't work. It adds to wrapper instead of modifying the