6

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

  • I am getting this same error. please help! – Connor Leech Sep 26 '13 at 13:34
  • Hi I used simple_form rails gem and here are my solution. <%= simple_form_for @user, :html => { :class => 'form-horizontal', :id => "create_user" } do |f| %> It is quite easy and you can refer railscast to install simple form. –  Sep 26 '13 at 18:06

4 Answers4

11

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"
davegson
  • 8,205
  • 4
  • 51
  • 71
  • Not that it's much help, but this fix worked for me. It's still pulling the old 3.2.6 version via rubygems.org as of 24th February, 2015. Adding the explicit locale fixed the issue. – tsujp Feb 24 '15 at 07:24
3

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!

grossadamm
  • 454
  • 3
  • 17
  • It's almost 2015 and this issue still exists with Rails 4. At least for now, this is the correct answer. – sixty4bit Dec 03 '14 at 14:38
  • Also, 4.0 beta branch doesn't seem to work for me. Just gives same error, except 5 for 4 arguments instead of 3 for 2. – sixty4bit Dec 03 '14 at 14:43
  • 1
    I haven't tried, but there is a 4-0-useable branch now. It is a little newer then the beta branch. The gem itself is not maintained anymore though, so I wouldn't expect it to work at all. – grossadamm Dec 04 '14 at 15:30
  • 1
    it is supported again, check [my answer](http://stackoverflow.com/a/28068535/2235594) – davegson Jan 21 '15 at 13:34
1

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

Nikhil Nanjappa
  • 6,454
  • 3
  • 28
  • 44
  • Hi, Thank you for your explanation. I used jquery validation instead of this. –  Feb 07 '14 at 04:58
  • Message from the linked gem's readme: "It's not recommended to use this gem. It's modified version of client_side_validations, which supports Rails 4. But I can't understand well the codebase, so no guarantee I'll continue to support it." The readme also mistakenly asserts that client_side_validations supports Rails 4. – sixty4bit Dec 03 '14 at 14:41
  • Also, 4.0 beta branch doesn't seem to work for me. Just gives same error, except 5 for 4 arguments instead of 3 for 2. – sixty4bit Dec 03 '14 at 14:44
0

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.

Matt
  • 13,948
  • 6
  • 44
  • 68
  • Yes I restarted my server. but error is still there. I am following the vedio on railscast http://railscasts.com/episodes/263-client-side-validations?view=asciicast –  Jun 12 '13 at 10:26
  • And you've done all the steps [here?](https://github.com/bcardarella/client_side_validations#install) , what version of rails are you using? how did you install the gem - did you `bundle install` ? – Matt Jun 12 '13 at 10:28
  • Yes i did......of course.......but i really don't understand why this error come.......I follow the same steps like in railscasts –  Jun 12 '13 at 15:06
  • Finally i remove client side validation and error disappear. But i need to use that in future. So, I want to know error root cause. –  Jun 12 '13 at 16:24