rails-api

Filter chain halted as :validate_sign_up_params rendered or redirected - devise_token_auth

丶灬走出姿态 提交于 2020-01-07 04:44:10
问题 I'm working on a ruby on rails API using devise_token_auth as authentication , and i'm getting this error everytime i'm making a API call from postman google chrom extension .below are my settings Gemfile gem 'devise' gem 'omniauth' gem 'devise_token_auth' gem 'byebug' gem 'rack-cors', :require => 'rack/cors' routes.rb mount_devise_token_auth_for 'User', at: 'auth' application_controller.rb include DeviseTokenAuth::Concerns::SetUserByToken before_action :authenticate_user! , :except=>[:new,

Rails, No 'Access-Control-Allow-Origin' header is present on the requested resource

我与影子孤独终老i 提交于 2020-01-05 09:35:27
问题 I have apps on Angular, which uses the server Ruby on Rails/oAuth backend. When registering a user in the console, I get these errors. POST*.herokuapp.com/api/users 500 (Internal Server Error) *.herokuapp.com/api/users:1 Failed to load *.herokuapp.com/api/users: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '*.herokuapp.com' is therefore not allowed access. The response had HTTP status code 500. /registration:1 { "isTrusted": true /auth.ts:95 } And other

Can't get JSON data from Rails API

末鹿安然 提交于 2019-12-24 01:44:48
问题 I make a get request to http://localhost:3000/cars/1 but server does not reply json data. It says like that Started GET "/api/cars/1" for 127.0.0.1 at 2016-10-07 12:47:34 +0600 Processing by Api::V1::CarsController#show as HTML Parameters: {"id"=>"1"} User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."uid" = $1 LIMIT $2 [["uid", "sahidul03@gmail.com"], ["LIMIT", 1]] Car Load (0.6ms) SELECT "cars".* FROM "cars" WHERE "cars"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]] User Load (1

rails5 api + devise_token_auth: no access-token and uid returns after login successfully via omniauth2

帅比萌擦擦* 提交于 2019-12-23 17:50:46
问题 I am using devise_token_auth for omniauth2 login with weibo and qq. Yes, I am trying to use rails5 api feature! After setup and using omniauth test_mode, I seems like login successfully but not login info( access_token, expiry, client and uid ) return in the header of response. Here is model, I apply candidate rather than user as authentication resource. #app/models/candidate.rb class Candidate < ApplicationRecord devise :database_authenticatable, :trackable, :omniauthable include

rails5 api + devise_token_auth: no access-token and uid returns after login successfully via omniauth2

走远了吗. 提交于 2019-12-23 17:42:01
问题 I am using devise_token_auth for omniauth2 login with weibo and qq. Yes, I am trying to use rails5 api feature! After setup and using omniauth test_mode, I seems like login successfully but not login info( access_token, expiry, client and uid ) return in the header of response. Here is model, I apply candidate rather than user as authentication resource. #app/models/candidate.rb class Candidate < ApplicationRecord devise :database_authenticatable, :trackable, :omniauthable include

Why does Rails RSpec response show 302 instead of 401?

寵の児 提交于 2019-12-23 09:32:13
问题 I have been stuck on this problem for several days and I don't know what is wrong with it. I started Ruby on Rails few months ago and I am currently learning authentication with API. I have looked at other similar topics here and there but none of them helped. My problem is whenever I run RSpec on this code (located at spec/api/v1/controllers/posts_controller_spec.rb ) require 'rails_helper' RSpec.describe Api::V1::PostsController, type: :controller do let(:my_user) { create(:user) } let(:my

CarrierWave full url for default image

a 夏天 提交于 2019-12-22 06:56:23
问题 I am using CarrierWave for image uploads on a rails-api application which in turn is consumed by a backbone.js client app. I notice that when there is no default image available it returns /assets/default.png . It in turn has to be http://dev-server:3000/assets/default.png . Here are my configuration settings: # config/environments/development.rb CarrierWave.configure do |config| config.asset_host = "http://dev-server:3000" end # Image Uploader .... def default_url "/assets/default.png" end

ActionController::RoutingError: uninitialized constant Api::V1::ApiController

怎甘沉沦 提交于 2019-12-22 05:32:26
问题 I have Rails 5 API project for controlling user tasks and I have the following error but not always for the same controller and route. ActionController::RoutingError: uninitialized constant Api::V1::ApiController I describe you a little bit my project to explain in more detail the error. App structure Routes scope module: 'api' do namespace :v1 do # => Login routes scope module: 'login' do match 'login', to: 'sessions#login', as: 'login', via: :post end # => Team routes scope module: 'team'

Rails API + AngularJS + Websocket-Rails gem

我与影子孤独终老i 提交于 2019-12-21 09:14:10
问题 My server is running the websocket-rails gem to handle websockets. I'm having trouble using websocket-rails with a phonegap project that uses angular because I need to initialize the websocket-rails client in my Angular front end independent of the rails asset pipeline. Is it possible to load the websocket-rails client separately into an angular project? Or can I use an angular socket directive to manange sockets with websocket-rails? 回答1: I managed to get this working. I translated all the

Setting Content-Type header for RSpec and Rails-API

坚强是说给别人听的谎言 提交于 2019-12-21 08:56:04
问题 I'm using the rails-api gem to build a web service and want to test my API with RSpec. Every request I make, regardless of the HTTP method has the CONTENT_TYPE header set as "application/x-www-form-urlencoded". This isn't really a problem until I try to use wrap_parameters in my controller and it's not have any affect on the params hash: class ApplicationController < ActionController::API include ActionController::ParamsWrapper end class ProjectsController < ApplicationController wrap