Closed hasyrails closed 4 years ago
ActionView::MissingTemplate (Missing template api/users/create, api/application_base/create, application/create with {:locale=>[:en], :formats=>[:json], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. Searched in:
$ curl -i -X POST http://localhost:3000/api/users.json -d 'user[email]=sample@ggg.com' -d 'user[name]=sample' -d 'user[password]=password' -d 'user[password_confirmation]=password'
Processing by Api::UserSessionsController#create as JSON
Parameters: {"user"=>{"email"=>"hoge@ggg.com", "password"=>"[FILTERED]"}}
Rendering api/user_sessions/create.json.jbuilder
Rendered api/user_sessions/create.json.jbuilder (0.3ms)
Completed 404 Not Found in 5ms (Views: 4.1ms | ActiveRecord: 0.0ms)
Started POST "/api/users.json" for ::1 at 2020-10-10 11:15:07 +0900
Processing by Api::UsersController#create as JSON
Parameters: {"user"=>{"email"=>"sample@ggg.com", "name"=>"sample", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}}
Unpermitted parameter: :name
(0.1ms) begin transaction
↳ app/controllers/api/users_controller.rb:27
User Create (0.4ms) INSERT INTO "users" ("email", "crypted_password", "salt", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["email", "sample@ggg.com"], ["crypted_password", "$2a$10$tKI0RONonl1hxU4f3N0oReIuBsp.YeeAZVSyYFE4NC41/TygqdU5q"], ["salt", "fuyhdHx5KnnyoHcL1RyD"], ["created_at", "2020-10-10 02:15:07.730458"], ["updated_at", "2020-10-10 02:15:07.730458"]]
↳ app/controllers/api/users_controller.rb:27
(1.8ms) commit transaction
↳ app/controllers/api/users_controller.rb:27
Completed 500 Internal Server Error in 70ms (ActiveRecord: 2.3ms)
ActionView::MissingTemplate (Missing template api/users/create, api/application_base/create, application/create with {:locale=>[:en], :formats=>[:json], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. Searched in:
* "/Users/shota/calendar-vue-original/app/views"
):
app/controllers/api/users_controller.rb:28:in `block (2 levels) in create'
app/controllers/api/users_controller.rb:26:in `create'
irb(main):023:0> User.all
User Load (0.7ms) SELECT "users".* FROM "users" LIMIT ? [["LIMIT", 11]]
=> #<ActiveRecord::Relation [#<User id: 15, email: "sample@ggg.com", crypted_password: "$2a$10$tKI0RONonl1hxU4f3N0oReIuBsp.YeeAZVSyYFE4NC4...", salt: "fuyhdHx5KnnyoHcL1RyD", created_at: "2020-10-10 02:15:07", updated_at: "2020-10-10 02:15:07">]>
curl -XPOST -H 'Content-Type: application/json' -d '{"email": "hoge@ggg.com", "password": "password"}' http://localhost:3000/api/user_sessions
Started POST "/api/user_sessions" for ::1 at 2020-10-10 11:20:18 +0900
Processing by Api::UserSessionsController#create as JSON
Parameters: {"email"=>"hoge@ggg.com", "password"=>"[FILTERED]", "user_session"=>{"email"=>"hoge@ggg.com", "password"=>"[FILTERED]"}}
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'hoge@ggg.com' ORDER BY "users"."id" ASC LIMIT ? [["LIMIT", 1]]
↳ app/controllers/api/user_sessions_controller.rb:9
Rendering api/user_sessions/create.json.jbuilder
Rendered api/user_sessions/create.json.jbuilder (0.4ms)
Completed 404 Not Found in 6ms (Views: 3.7ms | ActiveRecord: 0.7ms)
Started POST "/api/user_sessions.json" for ::1 at 2020-10-10 20:51:49 +0900
20:51:49 web.1 | Processing by Api::UserSessionsController#create as JSON
20:51:49 web.1 | Parameters: {"user"=>{"email"=>"sample@ggg.com", "password"=>"[FILTERED]"}}
20:51:49 web.1 | User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'sample@ggg.com' ORDER BY "users"."id" ASC LIMIT ? [["LIMIT", 1]]
20:51:49 web.1 | ↳ app/controllers/api/user_sessions_controller.rb:8
20:51:50 web.1 | Completed 500 Internal Server Error in 505ms (ActiveRecord: 0.6ms)
20:51:50 web.1 |
20:51:50 web.1 |
20:51:50 web.1 |
20:51:50 web.1 | NameError (uninitialized constant User::ApiKey):
20:51:50 web.1 |
20:51:50 web.1 | app/models/user.rb:46:in `api_key'
20:51:50 web.1 | app/models/user.rb:23:in `activate'
20:51:50 web.1 | app/controllers/api/user_sessions_controller.rb:11:in `create'
^_^_21:51:19 web.1 | Started GET "/login" for ::1 at 2020-10-10 21:51:19 +0900
21:51:20 web.1 | Processing by HomeController#index as HTML
21:51:20 web.1 | Parameters: {"path"=>"login"}
21:51:20 web.1 | Rendering home/index.html.erb within layouts/application
21:51:21 web.1 | Rendered home/index.html.erb within layouts/application (126.3ms)
22:22:42 web.1 | Completed 200 OK in 1881413ms (Views: 1881365.8ms | ActiveRecord: 0.0ms)
NameError (uninitialized constant User::ApiKey): ?
hayfever/sorcery-jwtの
login
メソッドを使っても治らず
Rails 4.2.1 sorcery 0.9.1 ver違いで動かない?
sorcery でapi認証を実装する
実装方針
[Ruby on Rails]sorceryによる認証 – (5)APIでの認証 #1 実装の概要