Rails 5中的客户端验证+ simple_form

时间:2016-08-15 20:44:01

标签: ruby-on-rails ruby simple-form client-side-validation

当我将以下内容放入我的gemfile中时:

gem 'simple_form'
gem 'client_side_validations'#, github: 'DavyJonesLocker/client_side_validations'
gem 'client_side_validations-simple_form'#, github: 'DavyJonesLocker/client_side_validations-simple_form'

结果如下:

Bundler could not find compatible versions for gem "rails":
  In Gemfile:
    rails (= 5.0.0)

    client_side_validations-simple_form was resolved to 3.2.0, which depends on
      client_side_validations (~> 4.2.0) was resolved to 4.2.0, which depends on
        rails (< 4.3.0, >= 4.0.0)

有关让这些宝石发挥作用的任何想法吗?

2 个答案:

答案 0 :(得分:5)

您可以通过指定分支来使用带有Rails 5的client_side_validations:

gem 'client_side_validations', 
    github: 'DavyJonesLocker/client_side_validations', 
    branch: 'rails5'

如果使用简单表格:

gem 'client_side_validations-simple_form', 
    github: 'DavyJonesLocker/client_side_validations-simple_form', 
    branch: 'rails5'

答案 1 :(得分:2)

Rails 5支持尚未准备好client_side_validations gem。看一下这个问题#645。您可以按照问题评论中的建议尝试实验分支。