forked from muratguzel/letsrate
-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
authentication issue #148
Comments
If anyone still needs it: I changed this $.post https://github.com/wazery/ratyrate/blob/master/lib/generators/ratyrate/templates/ratyrate.js.erb#L45-L60 to: $.ajax({
type: "POST",
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
url: '<%= Rails.application.class.routes.url_helpers.rate_path %>',
data: {
score: score,
dimension: $(this).attr('data-dimension'),
id: $(this).attr('data-id'),
klass: $(this).attr('data-classname')
},
success: function(data) {
if(data) {
if ($(_this).attr('data-disable-after-rate') == 'true') {
$(_this).raty('set', { readOnly: true, score: score });
}
}
},
}); to send X-CSRF-Token too and works well |
How to use above code so that existing gem will work?? |
@istiaqiut How did you get your problem solved?? |
I found it... Thanks... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I submit rating, I got the following errors
Parameters: {"score"=>"4", "dimension"=>"satisfaction", "id"=>"36", "klass"=>"Product"}
Can't verify CSRF token authenticity.
Completed 422 Unprocessable Entity in 1ms (ActiveRecord: 0.0ms)
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
The text was updated successfully, but these errors were encountered: