Tag: 简单forms的

SimpleForm + ClientSideValidations + bootstrap – 表单上没有validation – 所有输入都被接受

我在RoR应用程序中使用SimpleForm,ClientSideValidations和ClientSideValidations-SimpleForm gems。 我可以将表单精美地渲染到模态中,但是当输入失去焦点时,不会进行validation并提交表单。 另请注意,我尝试使用此处的修复程序: http : //www.ddarrensmith.com/blog/2012/05/17/ruby-on-rails-client-side-validation-with-validation-helpers-and- Twitter的引导/ 包含表单的视图的片段: x Create Discrepancy true, :url => {:controller=> ‘discrepancy’, :action => ‘create’, :device_id => @device.id} do |f| %> :prepend, :label => false do %> ‘add-on input-label’ %> :prepend, :label => false do %> ‘add-on input-label’ %> ‘textarea’ %> :prepend, :label => false do %> ‘add-on input-label’ %> […]

嵌套的simple_form,具有多态关联。 未经加工的参数

关于它的问题很多,但我找不到答案。 我有: group.rb class Group :describable accepts_nested_attributes_for :descriptions end description.rb class Description true end groups_controller.rb def update @group = Group.find(params[:id]) if @group.update_attributes(group_params) flash[:success] = “yes” redirect_to groups_path else render ‘edit’ end end private def group_params params.require(:group).permit(:owner_id, :domain, descriptions_attributes: [:id, :content]) end edit.html.erb 在控制台中我有Unpermitted parameter: description未创建Unpermitted parameter: description和嵌套属性。 我该怎么做才能最后保存?

在Simple Form Association中指定值

我正在尝试选择特定记录但是在尝试保存时, employee_id以空值保存,并且没有任何条件它正常工作,有什么方法可以解决这个问题吗? true).map(&:full_name) %>

Rails,简单表单和客户端validation不起作用

我的模特: class Hotel < ActiveRecord::Base attr_accessible :name belongs_to :user has_many :room_types validates :user_id, presence: true validates :name, presence: true, length: { in: 2..15 } end 表格代码: true do |f| %> ‘btn btn-primary’, :type => ‘submit’ %> 似乎没有执行任何客户端validation。 我可以在不填写任何信息的情况下提交表格。 有任何想法吗? 编辑:好的,我查看了我的页面的来源,它有这个错误: window [‘new_hotel’] = {“type”:“SimpleForm :: FormBuilder”,“error_class”:“DEPRECATION WARNING:[SIMPLE_FORM] SimpleForm.error_class已弃用且无效。(从(eval)的error_class调用:1 )“,”“error_tag”:“DEPRECATION警告:[SIMPLE_FORM] SimpleForm.error_tag已弃用且无效。(从(eval)的error_tag调用:1)”,“wrapper_error_class”:“DEPRECATION WARNING:[SIMPLE_FORM] SimpleForm。不推荐使用wrapper_error_class并且没有效果。(从(eval)的wrapper_error_class调用:1)“,”wrapper_tag“:”DEPRECATION警告:[SIMPLE_FORM] SimpleForm.wrapper_tag已弃用且无效。(在(eval)从wrapper_tag调用) :1)“,”validation者“:{”hotel [name]“:{”presence“:{”message“:”不能为空“},”length“:{”messages“:{”maximum“: […]

Rails Simple_Form:如何显示国家的长名称

我使用simple_form gem来选择国家: = simple_form_for @shop, :url => { :action => “create” }, :html => {:id => ‘new_shop’ } do |f| = f.simple_fields_for :address, :html => {:multipart => true} do |o| = o.input :country, :label => “Country” 但是国家的名称在数据库中以短格式保存(如RU , FR , AU等)。 我想知道,我怎样才能在观点中展示这个国家的完整长名? 谢谢!

Rails 4 -Simple表单如何保存键和显示值

我正在尝试在Rails 4中创建一个应用程序。我使用简单的表单forms。 我的模型中有一个名为“self_governance”的属性。 我编写了一个辅助方法,以便我可以定义5个级别,可以为这个属性存储,但是作为选项显示给用户(而不是数字1 .. 5)。 在我的帮手中,我有: module PreferencesHelper def self_gov_selector [ [ ‘tier 1′,’1’], [ ‘tier 2′,’2’], [ ‘tier 3′,’3’], [ ‘tier 4′,’4’], [ ‘tier 5′,’5′], ] end 在我的表格中,我有: “Select your tier”, collection: self_gov_selector %> 然后在我的节目中,我试图弄清楚如何显示’第1层’而不是’1’。 我试过了: 我发现任何有效的东西。 它们都在视图中显示1而不是第1层。 我怎样才能做到这一点?

Bootstrap3和简单的forms

以下命令将simple_form与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 it on http://twitter.github.com/bootstrap. Inside your views, use the ‘simple_form_for’ with one of the Bootstrap form classes, ‘.form-horizontal’, ‘.form-inline’, ‘.form-search’ or ‘.form-vertical’, […]

在rails 3.2.8引擎中加载simple_form的错误

在rails 3.2.8引擎中加载simple_form时,simple_form初始化文件simple_form.rb会导致错误: /config/initializers/simple_form.rb:2:in `’: uninitialized constant SimpleForm (NameError) from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:588:in `block (2 levels) in ‘ from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:587:in `each’ 在引擎的config / initializers下,simple_form.rb是: # Use this setup block to configure all options available in SimpleForm. SimpleForm.setup do |config| # Wrappers are used by the form builder to generate a # complete input. You can remove any component […]

ruby-on-rails client_side_validation simple_form javascript错误

Ruby on Rails应用程序并尝试添加client_side_validation工作并在访问屏幕字段时获得两个javascript运行时错误。 错误; 未捕获的TypeError:无法调用未定义的方法’add’ 未捕获的TypeError:无法调用未定义的方法’remove’ Gemfile source ‘https://rubygems.org’ …….. gem ‘simple_form’ gem ‘client_side_validations’ gem ‘client_side_validations-simple_form’ ….. application.html.erb “all” %> … 视图 – _form.html.erb true do |f| %> …. 该模型 class Basin < ActiveRecord::Base include ActiveModel::ForbiddenAttributesProtection belongs_to :country has_many :drills validates :country_id, :name, presence: true validates :name, uniqueness: {scope: [:country_id], message: "A country can only […]

无法更改simple_form中文本字段的高度

我试过了 #Default size for text inputs. config.default_input_size = 10 来自config / initializers / simple_form.rb 我也试过 {:size => 10} %> 但这些都没有改变我的文本字段的显示方式。