I have worked with jQuery remote function in the past, but in this case I'm having trouble.
I have a working remote function to check email uniqueness, but now I want to check user password, when he enters it using the jQuery validation plugin (if it is possible) but I constantly get in Firebug :
406 Not acceptable
Here is my action(PROBLEM IN HERE. EDIT): -EDIT
def checkpass
@user = User.find_by_email(params[:email])
if @user && @user.valid_password?(params[:user][:password])
@check = true
end
respond_to do |format|
format.json { render :json => @check }
end
end
From console: -EDIT
Started GET "/checkpass?user%5Bpassword%5D=[FILTERED]&email=new%40mail.com" for 127.0.0.1 at 2012-09-30 11:42:26 +0300
Processing by EditUserController#checkpass as JSON
Parameters: {"user"=>{"password"=>"[FILTERED]"}, "email"=>"new@mail.com", "pas
sword"=>"[FILTERED]"}
←[1m←[36mUser Load (0.0ms)←[0m ←[1mSELECT "users".* FROM "users" WHERE "users
"."email" = 'new@mail.com' LIMIT 1←[0m
User: new@mail.com
Pass: 123456
Devise pass:true
Completed 200 OK in 438ms (Views: 15.6ms | ActiveRecord: 0.0ms)
Here is WORKING action for checking email uniqueness :
def checkemail
@user = User.find_by_email(params[:user][:email])
respond_to do |format|
format.json { render :json => !@user }
end
end
and my jQuery validation with remote function -EDIT
$("#edit_password").validate({
rules: {
"user[password]":{
required: true,
minlength: 6,
remote: {
url: "http://127.0.0.1:3000/checkpass",
type: "get",
data: {
email: function() { return $("#user_email").val(); }
}
},
...
})
Working example of checkuniqeness jQuery:
"user[email]": {
required: true,
email: true,
remote: {
url: "http://127.0.0.1:3000/checkemail"
}
Where is my error ?