simple-form

Change only the image inside same div when option from dropdown is chosen

核能气质少年 提交于 2019-12-08 18:12:30
I have a nested form where you can add new bracelets to your order. For each bracelet you can choose a color, and next to the select (dropdown) where you choose the color there is an image with the bracelet on that color. The problem is this: When I add a new nested-fields div (form for new bracelet), when I select a color in the dropdown the image next to it doesn't change. Also, when I select a color in the dropdown for the first bracelet, the images for all the bracelets change to that color. This is the JQuery I'm using, where .product-still-form is the image. jQuery(function($) { $("

rails simple_nested_form_for fields_for wrong number of arguments

时间秒杀一切 提交于 2019-12-08 16:37:43
问题 So I'm building a form in rails 3.1, using <%= simple_nested_form_for(@person, :url => collection_url, :html=>{:multipart => true}) do |f| %> <%= render :partial => "form", :locals => { :f => f } %> <% end %> but this line in the partial is causing the problem: <h2>Badges</h2> <ul id="certifications"> // this following line is raising the error "wrong number of arguments (4 for 3)" <%= f.fields_for :certifications do |certification_form| %> <%= render :partial => 'certification', :locals => {

Filter field based on previous field selection

橙三吉。 提交于 2019-12-08 12:03:30
问题 How can I use simple_form to filter a field, based on a previous fields value? For instance, I have an Opportunities form, with two fields, Company and Contact. Company Field: <div class="form-group"> <%= f.association :company, collection: Company.all.order(:account), prompt: "", :label_method => :account, :value_method => :id %> </div> Contact Field: <div class="form-group"> <%= f.association :contact, collection: Contact.all.order(:first_name), prompt: "", :label_method => lambda {

omniauth identity not working on heroku with simple_form_for

ぃ、小莉子 提交于 2019-12-08 11:50:25
问题 I'm having trouble with Heroku not playing ball and throwing me this error ActionController::RoutingError (No route matches [POST] "/auth/identity/register"): I have the following working in dev. model/user.rb class User < OmniAuth::Identity::Models::ActiveRecord has_many :services controllers/users_controller.rb def new @user = env['omniauth.identity'] || User.new end users/new.html.erb <%= simple_form_for @user, url: "/auth/identity/register" do |f| %><fieldset> <legend><%= controller

Not wrapping css div with field_with_errors for fields created with f.text_field but works for f.input

拟墨画扇 提交于 2019-12-08 11:21:02
问题 I'm having problems with my views. I'm using zurb foundation for stylesheets and when I enter wrong input in forms I get the error above the form but the fields containing the errors are not wrapped with red. Looking further into this there is no field_with_errors div wrapper for the input fields. After looking further into this I found out if I use f.input instead of f.text_field I get the correct error wrapping. As zurb has styles for text_field, text_area etc. I'm using those but I don't

How can a dropdown be stylized when using twitter bootstrap with simple_form in a Rails app?

China☆狼群 提交于 2019-12-08 10:00:32
I am using simple_form and twitter-bootstrap-rails gems. Every thing is working fine but somehow drop-down is not getting stylized by twitter bootstrap rails ..it shows like normal forms. <%= f.input :category, :collection => ["one", "two", "three", "four"], :input_html => {:class => 'dropdown'}, :label => 'Send To', prompt: "Choose From List" %> IMAGE OF DROPDOWN SHOWING: IMAGE OF DROPDOWN NEEDED AS IN BOOTSTRAP One way to get stylized dropdowns with SimpleForm and Bootstrap is to use Bootstrap-Select . There is a Rails Gem for it; add to your Gemfile and do a bundle : gem 'bootstrap-select

has_many through form and adding attribute to join table

别等时光非礼了梦想. 提交于 2019-12-08 09:50:17
问题 This is my first stakoverflow question and fairly new to Rails. I've searched through previous similar questions but can't seem to figure this one out. I have a has_many through relationship with Users and Accounts and I have an extra boolean attribute "account_admin" on the UserAccount model (join table). I'm trying to figure out how to set this when I create a new Account. User: class User < ActiveRecord::Base has_many :user_accounts, :dependent => :destroy has_many :accounts, :through =>

Rails: simple_form association with i18n

纵然是瞬间 提交于 2019-12-08 08:55:58
问题 I have a question regarding the simple_form gem . If I have two languages and use the t('') function from to translate text, which I have put into my .yml files. When using <%= f.association :type %> , is it possible to let simple_form render <select value="database_value1">t('database_value1')</select> ? Thank you 回答1: Possibly, it'll translate collections for you: https://github.com/plataformatec/simple_form Association docs: http://rubydoc.info/github/plataformatec/simple_form/master

Rails Forms : change form fields from previously selected fields

早过忘川 提交于 2019-12-08 08:54:16
问题 I have two simple_form fields like this: <%= f.input :ration_card ,as: :radio_buttons,collection: ["Yes","No"], input_html: {id: "rationcard"} %> <%= f.input :rationcardNum , label: "Ration Card No." ,input_html: {id: "rationcard_no"} %> I want to show the second field only if user selects "Yes" for the first field. My Jquery: $(function(){ $("#rationcard").change(function(){ if ($("#rationcard").val()=="Yes"){ $("#rationcard_no").show(); } else { $("#rationcard_no").hide(); } }) }) I can see

Bootstrap3 and simple form

人走茶凉 提交于 2019-12-08 08:39:24
问题 The following command integrates simple_form with twitter-bootstrap $ rails g simple_form:install --bootstrap identical config/initializers/simple_form.rb create config/initializers/simple_form_bootstrap.rb exist config/locales identical config/locales/simple_form.en.yml identical lib/templates/erb/scaffold/_form.html.erb =============================================================================== Be sure to have a copy of the Bootstrap stylesheet available on your application, you can get