Rails' client-side-validation form_for error

北慕城南 提交于 2019-12-18 05:01:34

问题


I am using client validation rails gem and I got this error. Any idea.....

wrong number of arguments (3 for 2) Extracted source (around line #1):

<%= form_for @user, :validate => true do |f| %>

Trace of template inclusion: app/views/users/new.html.erb


回答1:


Based on https://github.com/bcardarella/client_side_validations/issues/494 it looks like CSV will not support Rails 4 for a little bit longer.

However it also states

I don't see CSV 4.0 coming out for at least 2 months after Rails 4.0 lands (hopefully not that long) as there will be major changes on the JavaScript side of things. Because it will take so longer and people will want a Rails 4.0 compliant version of CSV suggesting they use master branch or perhaps releasing a alpha or pre version to partially satisfy them while we update might be the correct option.

So perhaps try pulling csv right from git? There is a 4.0 beta branch that might be worth trying...

Update

The CSV gem is no longer actively maintained. There are 3 different 4.0 branches on the repository, and the most recently updated of which is 4-0-useable (https://github.com/bcardarella/client_side_validations/branches/all).

Update 2

As @TheChamp says, the CSV gem now supports rails 4.2!




回答2:


Rails 4 Support

Thanks to tagliala & bcardarella, the client_side_validation gem now supports rails 4!

After adding

gem 'client_side_validations'

to my Gemfile, it didn't load everything properly.

This may be temporarily, as Rubygems only links the old version. Instead I had to specify the exact repository & branch, since the owner changed.

gem 'client_side_validations', github: "DavyJonesLocker/client_side_validations", branch: "4-2-stable"



回答3:


If your using Rails 4 then Client Side validation is outdated. You can check here

http://railscasts.com/episodes/263-client-side-validations?view=comments

and also if you go to the github page

https://github.com/bcardarella/client_side_validations

you can see that it says its no longer maintained.

Alternatively you can try using the CSV gem from this branch, by replacing the CSV line in your Gemfile by this

gem 'client_side_validations', github: "bcardarella/client_side_validations", :branch => "4-0-beta"

Not sure even if this will work though. Since its outdated.

Or you can check this gem out,

https://github.com/kalkov/rails4_client_side_validations

Its just a modified version of Client Side Validations




回答4:


Have you followed all of the instructions on the github page? If so, have you restarted your server? The install adds an initializer that wont take effect until a server restart.



来源:https://stackoverflow.com/questions/17062896/rails-client-side-validation-form-for-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!