i am encoding a chromium extension that connects to a ruby server in order to save or send a reminder notification when the time comes, the connection works and it is possible for the user to create a reminder (on our ruby server) since the extension. my problem is during the sign_in that I would like to be able to do since the extension in order to recover authanticity_token, when I send the request to the server I have an error in javascript console type:
XHR failed loading: OPTIONS "http://localhost:3000/users/sign_in".
send @ jquery.js:4
ajax @ jquery.js:4
ajaxLogin @ log_in.js:26
(anonymous) @ log_in.js:13
dispatch @ jquery.js:3
r.handle @ jquery.js:3
11:39:05.127 Navigated to file:///home/eth3r/Bureau/WaltTest/walt-e/log_in.html
and in ruby's console :
Started OPTIONS "/users/sign_in" for 127.0.0.1 at 2017-09-01 11:49:27 +0200
ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
ActionController::RoutingError (No route matches [OPTIONS] "/users/sign_in"):
routes.rb
Rails.application.routes.draw do
devise_for :users, controllers: {
sessions: 'sessions',
registrations: 'registrations'
}
resources :reminders, only: [:new, :create, :edit, :destroy, :index, :update]
root to: 'pages#home'
namespace :api, defaults: { format: :json } do
namespace :v1 do
resources :reminders, only: [:new, :create, :edit, :destroy, :index, :update]
end
end
end
my ajax function :
function ajaxLogin(email, password) {
var data = {
"user": {
"email": email,
"password": password,
}
};
$.ajax({
type: "POST",
url: apiBaseUrl + "/users/sign_in",
headers: ajaxHeaders,
data: data,
dataType: "json",
contentType : "application/json",
success: function(data) {
console.log(data);
},
error: function(jqXHR, status, text) {
console.log(status);
console.log(text);
console.error(jqXHR.responseText);
}
});
};
I've been on the same problem for two days now, javascript is horrible!