Minitest and Devise integration test is not updating the resource/model - ruby-on-rails

So I have this resource (User) that I am trying to test the updating of. I am using Ruby 3.0.1, Rails 6.1.4, Devise 4.8.1, and Recaptcha 5.8.1. Here's the User:
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable, :trackable,
:recoverable, :rememberable, :validatable, :confirmable
include Elasticsearch::Model
scope :visible_to_public, -> { where(searchable: true) }
scope :activated, -> { where('users.confirmed_at IS NOT NULL') }
index_name "users-#{Rails.env}"
has_one_attached :avatar
has_many :widgets, dependent: :destroy
has_many :active_relationships, class_name: "Relationship",
foreign_key: "follower_id",
dependent: :destroy
has_many :passive_relationships, class_name: "Relationship",
foreign_key: "followed_id",
dependent: :destroy
has_many :following, through: :active_relationships, source: :followed
has_many :followers, through: :passive_relationships, source: :follower
has_many :reports, dependent: :destroy
has_many :comments, dependent: :destroy
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+#[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, length: { maximum: 255 },
format: { with: VALID_EMAIL_REGEX },
uniqueness: true
Here's the test:
test "successful edit" do
sign_in #user, scope: :user
name = "Foo Bar"
handle = "MrFoo"
put user_registration_path, params: { user: { name: name,
username: handle,
email: #user.email,
password: '',
password_confirmation:'',
current_password: #user.current_password }}
assert_response :success
puts "User Errors: #{#user.errors.full_messages}\n"
#user.reload
puts "User: #{#user.inspect}\n"
assert_equal name, #user.name
assert_equal handle, #user.username
end
The assert_equal name is failing and the User errors from the put statement in the test is an empty array '[]'.
I created a Devise Registration controller so I could use the recaptcha gem. It has very little code. Here it is:
class Users::RegistrationsController < Devise::RegistrationsController
before_action :configure_sign_up_params, only: [:create]
before_action :configure_account_update_params, only: [:update]
def update
if verify_recaptcha
super
else
self.resource = resource_class.new sign_up_params
flash.now[:error] = "Recaptcha cannot be blank; please try again"
redirect_to edit_user_registration_path
end
end
protected
# If you have extra params to permit, append them to the sanitizer.
def configure_sign_up_params
sign_up_attrs = [:password, :password_confirmation, :name, :username, :avatar]
devise_parameter_sanitizer.permit(:sign_up, keys: [sign_up_attrs])
end
# If you have extra params to permit, append them to the sanitizer.
def configure_account_update_params
update_attrs = [:password, :password_confirmation, :current_password, :name, :username, :avatar]
devise_parameter_sanitizer.permit(:account_update, keys: [update_attrs])
end
end
Here's the log:
-----------------------------------
UsersEditTest: test_successful_edit
-----------------------------------
[1m[36mUser Load (0.4ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 688598839], ["LIMIT", 1]]
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 838564783], ["LIMIT", 1]]
Started PUT "/users" for 127.0.0.1 at 2022-01-25 17:32:25 -0500
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mSAVEPOINT active_record_1[0m
[1m[36mUser Update (0.4ms)[0m [1m[33mUPDATE "users" SET "updated_at" = ?, "sign_in_count" = ?, "current_sign_in_at" = ?, "last_sign_in_at" = ?, "current_sign_in_ip" = ?, "last_sign_in_ip" = ? WHERE "users"."id" = ?[0m [["updated_at", "2022-01-25 22:32:25.237068"], ["sign_in_count", 1], ["current_sign_in_at", "2022-01-25 22:32:25.236226"], ["last_sign_in_at", "2022-01-25 22:32:25.236226"], ["current_sign_in_ip", "127.0.0.1"], ["last_sign_in_ip", "127.0.0.1"], ["id", 688598839]]
[1m[36mActiveStorage::Attachment Load (0.1ms)[0m [1m[34mSELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = ? AND "active_storage_attachments"."record_type" = ? AND "active_storage_attachments"."name" = ? LIMIT ?[0m [["record_id", 688598839], ["record_type", "User"], ["name", "avatar"], ["LIMIT", 1]]
[1m[36mUser Exists? (0.2ms)[0m [1m[34mSELECT 1 AS one FROM "users" WHERE "users"."email" = ? AND "users"."id" != ? LIMIT ?[0m [["email", "nick#example.com"], ["id", 688598839], ["LIMIT", 1]]
[1m[36mActiveStorage::Blob Load (0.2ms)[0m [1m[34mSELECT "active_storage_blobs".* FROM "active_storage_blobs" INNER JOIN "active_storage_attachments" ON "active_storage_blobs"."id" = "active_storage_attachments"."blob_id" WHERE "active_storage_attachments"."record_id" = ? AND "active_storage_attachments"."record_type" = ? AND "active_storage_attachments"."name" = ? LIMIT ?[0m [["record_id", 688598839], ["record_type", "User"], ["name", "avatar"], ["LIMIT", 1]]
[1m[36mActiveStorage::Blob Create (0.4ms)[0m [1m[32mINSERT INTO "active_storage_blobs" ("key", "filename", "content_type", "metadata", "byte_size", "checksum", "created_at", "service_name") VALUES (?, ?, ?, ?, ?, ?, ?, ?)[0m [["key", "c8w5ycv9gy4c67phehpbdvwxdigo"], ["filename", "default_avatar2.png"], ["content_type", "image/png"], ["metadata", "{\"identified\":true}"], ["byte_size", 15693], ["checksum", "4IDAjCeSqMrDM9F9s68Wtw=="], ["created_at", "2022-01-25 22:32:25.271303"], ["service_name", "test"]]
[1m[36mActiveStorage::Attachment Create (0.3ms)[0m [1m[32mINSERT INTO "active_storage_attachments" ("name", "record_type", "record_id", "blob_id", "created_at") VALUES (?, ?, ?, ?, ?)[0m [["name", "avatar"], ["record_type", "User"], ["record_id", 688598839], ["blob_id", 1], ["created_at", "2022-01-25 22:32:25.273083"]]
[1m[36mUser Update (0.1ms)[0m [1m[33mUPDATE "users" SET "updated_at" = ? WHERE "users"."id" = ?[0m [["updated_at", "2022-01-25 22:32:25.274730"], ["id", 688598839]]
[1m[36mTRANSACTION (0.1ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
[36m Disk Storage (0.7ms) [0m[32mUploaded file to key: c8w5ycv9gy4c67phehpbdvwxdigo (checksum: 4IDAjCeSqMrDM9F9s68Wtw==)[0m
[ActiveJob] Enqueued ActiveStorage::AnalyzeJob (Job ID: c2fffb8c-2df4-4224-a96c-38e6185954b8) to Test(active_storage_analysis) with arguments: #<GlobalID:0x000055cf7cde5098 #uri=#<URI::GID gid://saverd/ActiveStorage::Blob/1>>
Processing by Users::RegistrationsController#update as HTML
Parameters: {"user"=>{"name"=>"Foo Bar", "username"=>"MrFoo", "email"=>"nick#example.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "current_password"=>"[FILTERED]"}}
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 688598839], ["LIMIT", 1]]
[1m[36mUser Exists? (0.1ms)[0m [1m[34mSELECT 1 AS one FROM "users" WHERE "users"."email" = ? AND "users"."id" != ? LIMIT ?[0m [["email", "nick#example.com"], ["id", 688598839], ["LIMIT", 1]]
Rendering layout layouts/application.html.erb
Rendering users/registrations/edit.html.erb within layouts/application
Rendered users/shared/_error_messages.html.erb (Duration: 1.5ms | Allocations: 949)
[1m[36mActiveStorage::Attachment Load (0.3ms)[0m [1m[34mSELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = ? AND "active_storage_attachments"."record_type" = ? AND "active_storage_attachments"."name" = ? LIMIT ?[0m [["record_id", 688598839], ["record_type", "User"], ["name", "avatar"], ["LIMIT", 1]]
[1m[36mActiveStorage::Blob Load (0.1ms)[0m [1m[34mSELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ?[0m [["id", 1], ["LIMIT", 1]]
Rendered users/registrations/edit.html.erb within layouts/application (Duration: 12.9ms | Allocations: 7556)
[Webpacker] Everything's up-to-date. Nothing to do
Rendered layouts/_shim.html.erb (Duration: 0.3ms | Allocations: 85)
Rendered layouts/_head.html.erb (Duration: 4.1ms | Allocations: 1988)
[36m Disk Storage (0.1ms) [0m[34mChecked if file exists at key: variants/c8w5ycv9gy4c67phehpbdvwxdigo/f0565870533d712d9f81cf6c91b03ed2afd53144cf67b4fdca912bf91444366f (no)[0m
[36m Disk Storage (0.1ms) [0m[34mDownloaded file from key: c8w5ycv9gy4c67phehpbdvwxdigo[0m
[36m Disk Storage (0.4ms) [0m[32mUploaded file to key: variants/c8w5ycv9gy4c67phehpbdvwxdigo/f0565870533d712d9f81cf6c91b03ed2afd53144cf67b4fdca912bf91444366f[0m
[1m[35m (0.2ms)[0m [1m[34mSELECT COUNT(*) FROM "widgets" WHERE "widgets"."user_id" = ?[0m [["user_id", 688598839]]
Rendered shared/_user_info.html.erb (Duration: 90.4ms | Allocations: 3974)
[1m[35m (0.2ms)[0m [1m[34mSELECT COUNT(*) FROM "users" INNER JOIN "relationships" ON "users"."id" = "relationships"."followed_id" WHERE "relationships"."follower_id" = ?[0m [["follower_id", 688598839]]
[1m[35m (0.2ms)[0m [1m[34mSELECT COUNT(*) FROM "users" INNER JOIN "relationships" ON "users"."id" = "relationships"."follower_id" WHERE "relationships"."followed_id" = ?[0m [["followed_id", 688598839]]
Rendered shared/_stats.html.erb (Duration: 10.6ms | Allocations: 2077)
Rendered shared/_user_widget_search.html.erb (Duration: 2.4ms | Allocations: 429)
[1m[35m (0.3ms)[0m [1m[34mSELECT COUNT(*) FROM "widgets" INNER JOIN "widget_references" ON "widgets"."id" = "widget_references"."referenced_id" WHERE "widget_references"."referencer_id" = ?[0m [["referencer_id", 688598839]]
[1m[35mCACHE (0.0ms)[0m [1m[34mSELECT COUNT(*) FROM "widgets" WHERE "widgets"."user_id" = ?[0m [["user_id", 688598839]]
Rendered shared/_widget_box.html.erb (Duration: 5.2ms | Allocations: 1066)
[1m[35m (0.2ms)[0m [1m[34mSELECT COUNT(*) FROM "categories"[0m
[1m[36mCategory Load (0.3ms)[0m [1m[34mSELECT "categories".* FROM "categories" ORDER BY "categories"."sequence" ASC[0m
Rendered shared/_categories.html.erb (Duration: 11.0ms | Allocations: 4993)
Rendered shared/_sidebar_user.html.erb (Duration: 133.4ms | Allocations: 13724)
Rendered layouts/_header.html.erb (Duration: 136.2ms | Allocations: 14611)
Rendered shared/_alerts.html.erb (Duration: 0.7ms | Allocations: 185)
Rendered layouts/_footer.html.erb (Duration: 1.0ms | Allocations: 310)
Rendered layout layouts/application.html.erb (Duration: 158.3ms | Allocations: 25688)
Completed 200 OK in 172ms (Views: 159.2ms | ActiveRecord: 2.1ms | Allocations: 33566)
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 688598839], ["LIMIT", 1]]
[1m[36mTRANSACTION (0.4ms)[0m [1m[31mrollback transaction[0m
When I run the server and do this manually it works. I also have turbo disabled on all of my forms. I'm stumped.

Related

Update Test fails: "Expected response to be a <3XX: redirect>, but was a <204: No Content>"

I wanted to run this test, but it gives me an error an I don't understand why since hours.
Here is the complete error:
FAIL["test_should_update_preference", Minitest::Result, 2.7792289879871532]
test_should_update_preference#Minitest::Result (2.78s)
Expected response to be a <3XX: redirect>, but was a <204: No Content>
Response body:
test/controllers/preferences_controller_test.rb:20:in `block in <class:PreferencesControllerTest>'
Thanks to everyone who looks at my problem!
This is the test:
test "should update preference" do
patch preference_url(#preference), params: { preference: { accepted: #preference.accepted, institute_id: #preference.institute_id, preference_value: #preference.preference_value, user_id: #preference.user_id, wei_preference_value: #preference.wei_preference_value } }
assert_redirected_to preferences_path
end
Here is the Controller:
class PreferencesController < ApplicationController
before_action :set_preference, only: [:show, :edit, :update, :destroy]
# GET /preferences
# GET /preferences.json
def index
#preferences = Preference.all
end
# GET /preferences/1
# GET /preferences/1.json
def show
end
# GET /preferences/new
def new
#preference = Preference.new
end
# GET /preferences/1/edit
def edit
end
# POST /preferences
# POST /preferences.json
def create
#preference = Preference.new(preference_params)
respond_to do |format|
if #preference.save
format.html { redirect_to preferences_path}
else
format.html { render :index }
format.json { render json: #preference.errors, status: :unprocessable_entity }
end
end
end
def create_all
#institutes = Institute.all
#institutes.each do |li|
#preference = Preference.create(institute_id: li.id, user_id: current_user.id, preference_value: 5)
end
lash[:success] = "Sie können die Präferenzen jetzt bearbeiten."
render :index
end
# PATCH/PUT /preferences/1
# PATCH/PUT /preferences/1.json
def update
if #preference.update_attributes(preference_params)
flash[:success] = "Die Präferenz wurde aktualisiert."
redirect_to preferences_path
end
end
# DELETE /preferences/1
# DELETE /preferences/1.json
def destroy
#preference.destroy
respond_to do |format|
format.html { redirect_to preferences_url }
end
end
And this is the log-file, which I get, when I perform the Update task in my brwoser:
Started PATCH "/preferences/43" for 127.0.0.1 at 2018-03-02 15:36:06 +0100
Processing by PreferencesController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"CXcMiSLQdlUeJf75g/uClWaI89f/nxypzb60yphXh26sJx5E0bUu39SAEckE13GeozuCN9WQ3eBUTbPz1/WqoQ==", "preference"=>{"user_id"=>"2", "institute_id"=>"1", "preference_value"=>"1"}, "commit"=>"Speichern", "id"=>"43"}
[1m[36mPreference Load (0.3ms)[0m [1m[34mSELECT "preferences".* FROM "preferences" WHERE "preferences"."id" = ? LIMIT ?[0m [["id", 43], ["LIMIT", 1]]
[1m[35m (0.2ms)[0m [1m[36mbegin transaction[0m
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 1], ["LIMIT", 1]]
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 2], ["LIMIT", 1]]
[1m[35mSQL (31.4ms)[0m [1m[33mUPDATE "preferences" SET "preference_value" = ?, "updated_at" = ? WHERE "preferences"."id" = ?[0m [["preference_value", 1], ["updated_at", "2018-03-02 14:36:06.852000"], ["id", 43]]
[1m[35m (23.5ms)[0m [1m[36mcommit transaction[0m
Redirected to http://localhost:3000/preferences
Completed 302 Found in 76ms (ActiveRecord: 55.6ms)
Started GET "/preferences" for 127.0.0.1 at 2018-03-02 15:36:06 +0100
Processing by PreferencesController#index as HTML
Rendering preferences/index.html.erb within layouts/application
[1m[36mUser Load (0.1ms)[0m [1m[34mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?[0m [["id", 2], ["LIMIT", 1]]
[1m[36mPreference Exists (0.2ms)[0m [1m[34mSELECT 1 AS one FROM "preferences" WHERE "preferences"."user_id" = ? LIMIT ?[0m [["user_id", 2], ["LIMIT", 1]]
[1m[36mPreference Load (0.4ms)[0m [1m[34mSELECT "preferences".* FROM "preferences" WHERE "preferences"."user_id" = ?[0m [["user_id", 2]]
[1m[36mInstitute Load (0.3ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 1], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 2], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 3], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 4], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 5], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 6], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 7], ["LIMIT", 1]]
[1m[36mInstitute Load (0.4ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 8], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 9], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 10], ["LIMIT", 1]]
[1m[36mInstitute Load (0.5ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 11], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 12], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 13], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 14], ["LIMIT", 1]]
[1m[36mInstitute Load (0.3ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 15], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 16], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 17], ["LIMIT", 1]]
[1m[36mInstitute Load (0.2ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 18], ["LIMIT", 1]]
[1m[36mInstitute Load (0.2ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 19], ["LIMIT", 1]]
[1m[36mInstitute Load (0.4ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 20], ["LIMIT", 1]]
[1m[36mInstitute Load (0.1ms)[0m [1m[34mSELECT "institutes".* FROM "institutes" WHERE "institutes"."id" = ? LIMIT ?[0m [["id", 21], ["LIMIT", 1]]
Rendered preferences/index.html.erb within layouts/application (74.8ms)
Rendered layouts/_rails_default.html.erb (191.3ms)
Rendered layouts/_shim.html.erb (3.5ms)
Rendered layouts/_header.html.erb (19.9ms)
Rendered layouts/_footer.html.erb (1.4ms)
Completed 200 OK in 326ms (Views: 317.8ms | ActiveRecord: 4.4ms)
In your update method if your update_attributes method call fails, it doesn't render anything, which is why you're getting the No Content error.
First off, you should add an else statement to that method to so that it doesn't come back with no content. Rendering some sort of error status will do. Then you should put a debugger and see why it's failing. You can use the .errors method on the instance to see why it's not valid.
Thanks for the advice! I updated my controller and put an else statement into the controller.
def update
if #preference.update_attributes(preference_params)
flash[:success] = "Die Präferenz wurde aktualisiert."
redirect_to preferences_path
else
flash[:error] = "Die Präferenz konnte nicht aktualisiert werden."
redirect_to preference_path
end
end
now the test would be successful if I put preferences_path into the else action. That's not really the goal of my test so I put institute_path instead of preference_path in the else statement. Now I got the failure:
FAIL["test_should_update_preference", Minitest::Result, 1.8134876039985102]
test_should_update_preference#Minitest::Result (1.82s)
Expected response to be a redirect to <http://www.example.com/preferences> but was a redirect to <http://www.example.com/institutes>.
Expected "http://www.example.com/preferences" to be === "http://www.example.com/institutes".
test/controllers/preferences_controller_test.rb:20:in `block in <class:PreferencesControllerTest>'
I will Google the .error method and apply it to report what the mistake was.

rails devise - authentication google - can create but not login

When I create a new account using google authentication, it creates a account and also do the login automaticaly.
If I click logout and later login again, with the same google account, I can't login...
I get no error message :(
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
#user = User.from_omniauth(request.env["omniauth.auth"])
if #user.persisted?
sign_in_and_redirect #user, event: :authentication
set_flash_message(:notice, :success, kind: "Facebook") if is_navigational_format?
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
def google_oauth2
#user = User.from_omniauth(request.env["omniauth.auth"])
if #user.persisted?
sign_in_and_redirect #user, event: :authentication
set_flash_message(:notice, :success, kind: "Google") if is_navigational_format?
else
session["devise.google_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
end
Another informations.
Here is the log when the autentication / account creation works:
Started GET "/auth/google_oauth2" for 177.207.232.141 at 2016-10-23 23:47:31 +0000
Started GET "/auth/google_oauth2/callback?state=1f3b3124e0264c1dabb3f40059d9a15a9da524553e0ec5dc&code=4/ZjqBwsoXJJXncItmMDuwPssw0ooT1RwnNjkRIfilQYc" for 177.207.232.141 at 2016-10-23 23:47:33 +0000
Processing by OmniauthCallbacksController#google_oauth2 as HTML
Parameters: {"state"=>"1f3b3124e0264c1dabb3f40059d9a15a9da524553e0ec5dc", "code"=>"4/ZjqBwsoXJJXncItmMDuwPssw0ooT1RwnNjkRIfilQYc"}
[1m[35mSubdomain Load (27.7ms)[0m SELECT "subdomains".* FROM "subdomains" WHERE "subdomains"."address" = $1 LIMIT 1 [["address", "yoga"]]
[1m[36mDomain Load (27.5ms)[0m [1mSELECT "domains".* FROM "domains" WHERE "domains"."address" = $1 LIMIT 1[0m [["address", "smartmarket.io"]]
[1m[35mUser Load (28.0ms)[0m SELECT "users".* FROM "users" WHERE "users"."provider" = $1 AND "users"."uid" = $2 ORDER BY "users"."id" ASC LIMIT 1 [["provider", "google_oauth2"], ["uid", "110174173081848856467"]]
[1m[36m (27.7ms)[0m [1mBEGIN[0m
[1m[35mUser Exists (27.8ms)[0m SELECT 1 AS one FROM "users" WHERE "users"."email" = 'diogowernik#gmail.com' LIMIT 1
[1m[36mUser Exists (27.8ms)[0m [1mSELECT 1 AS one FROM "users" WHERE "users"."email" = 'diogowernik#gmail.com' LIMIT 1[0m
[1m[35mSQL (27.9ms)[0m INSERT INTO "users" ("provider", "uid", "name", "email", "image", "encrypted_password", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["provider", "google_oauth2"], ["uid", "really?"], ["name", "Diogo Wernik"], ["email", "diogowernik#gmail.com"], ["image", "https://lh6.googleusercontent.com/-vXjHRteu8BY/AAAAAAAAAAI/AAAAAAAAB3A/_oEJPVq8h8o/photo.jpg"], ["encrypted_password", "$2a$10$6CIsOntiZxoLQfyUTfskiuys3P4u6.M0O4h/4S5zoW7EpN2KgX4Re"], ["created_at", "2016-10-23 23:47:34.023034"], ["updated_at", "2016-10-23 23:47:34.023034"]]
[1m[36mSQL (28.1ms)[0m [1mINSERT INTO "profiles" ("name", "kind", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"[0m [["name", "Diogo Wernik"], ["kind", "blog"], ["user_id", 5], ["created_at", "2016-10-23 23:47:34.082199"], ["updated_at", "2016-10-23 23:47:34.082199"]]
[1m[35mSQL (28.4ms)[0m INSERT INTO "user_main_profiles" ("profile_id", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["profile_id", 5], ["user_id", 5], ["created_at", "2016-10-23 23:47:34.140877"], ["updated_at", "2016-10-23 23:47:34.140877"]]
[1m[36mUserMainProfile Load (27.7ms)[0m [1mSELECT "user_main_profiles".* FROM "user_main_profiles" WHERE "user_main_profiles"."user_id" = $1 LIMIT 1[0m [["user_id", 5]]
[1m[35m (28.1ms)[0m COMMIT
[1m[36mUser Load (27.9ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1[0m [["id", 1]]
[1m[35m (27.5ms)[0m BEGIN
[1m[36mSQL (27.9ms)[0m [1mUPDATE "users" SET "last_sign_in_at" = $1, "current_sign_in_at" = $2, "last_sign_in_ip" = $3, "current_sign_in_ip" = $4, "sign_in_count" = $5, "updated_at" = $6 WHERE "users"."id" = $7[0m [["last_sign_in_at", "2016-10-23 23:47:34.301029"], ["current_sign_in_at", "2016-10-23 23:47:34.301029"], ["last_sign_in_ip", "177.207.232.141/32"], ["current_sign_in_ip", "177.207.232.141/32"], ["sign_in_count", 1], ["updated_at", "2016-10-23 23:47:34.329926"], ["id", 5]]
[1m[35m (28.0ms)[0m COMMIT
Redirected to http://yoga.smartmarket.io/
Completed 302 Found in 636ms (ActiveRecord: 418.1ms)
[1m[36m (27.5ms)[0m [1mBEGIN[0m
[1m[35mSQL (27.7ms)[0m DELETE FROM "sessions" WHERE "sessions"."id" = $1 [["id", 11]]
[1m[36m (27.9ms)[0m [1mCOMMIT[0m
Here is when i logout and try to login again with the same account
Started GET "/auth/google_oauth2" for 177.207.232.141 at 2016-10-23 23:51:13 +0000
Started GET "/auth/google_oauth2/callback?state=ca339595a33e9e192c274a78450400a02e7edfd7f7ebb937&code=4/bQ59Fm5Fcxv_vWtBlFpMAwMoY6iig8J6bZGWFKboZms" for 177.207.232.141 at 2016-10-23 23:51:14 +0000
Processing by OmniauthCallbacksController#google_oauth2 as HTML
Parameters: {"state"=>"ca339595a33e9e192c274a78450400a02e7edfd7f7ebb937", "code"=>"4/bQ59Fm5Fcxv_vWtBlFpMAwMoY6iig8J6bZGWFKboZms"}
[1m[35mSubdomain Load (27.6ms)[0m SELECT "subdomains".* FROM "subdomains" WHERE "subdomains"."address" = $1 LIMIT 1 [["address", "yoga"]]
[1m[36mDomain Load (27.5ms)[0m [1mSELECT "domains".* FROM "domains" WHERE "domains"."address" = $1 LIMIT 1[0m [["address", "smartmarket.io"]]
[1m[35mUser Load (27.9ms)[0m SELECT "users".* FROM "users" WHERE "users"."provider" = $1 AND "users"."uid" = $2 ORDER BY "users"."id" ASC LIMIT 1 [["provider", "google_oauth2"], ["uid", "110174173081848856467"]]
[1m[36m (27.7ms)[0m [1mBEGIN[0m
[1m[35mUser Exists (28.5ms)[0m SELECT 1 AS one FROM "users" WHERE "users"."email" = 'diogowernik#gmail.com' LIMIT 1
[1m[36mUser Exists (28.0ms)[0m [1mSELECT 1 AS one FROM "users" WHERE "users"."email" = 'diogowernik#gmail.com' LIMIT 1[0m
[1m[35m (27.8ms)[0m ROLLBACK
Redirected to http://yoga.smartmarket.io/sign_up
Completed 302 Found in 271ms (ActiveRecord: 195.0ms)
Started GET "/sign_up" for 177.207.232.141 at 2016-10-23 23:51:15 +0000
Processing by Devise::RegistrationsController#new as HTML
[1m[36mSubdomain Load (27.5ms)[0m [1mSELECT "subdomains".* FROM "subdomains" WHERE "subdomains"."address" = $1 LIMIT 1[0m [["address", "yoga"]]
[1m[35mDomain Load (27.7ms)[0m SELECT "domains".* FROM "domains" WHERE "domains"."address" = $1 LIMIT 1 [["address", "smartmarket.io"]]
Rendered devise/registrations/_social.erb (0.5ms)
Rendered devise/registrations/new.html.erb within layouts/application (2.0ms)
Rendered layouts/partials/_topnavbar.html.erb (0.4ms)
Rendered layouts/partials/_sidebar.html.erb (0.1ms)
Rendered layouts/partials/_footer.html.erb (0.0ms)
Rendered layouts/partials/_alerts.erb (0.1ms)
Completed 200 OK in 251ms (Views: 165.2ms | ActiveRecord: 83.0ms)
Started GET "/api/i18n/site-pt.json" for 177.207.232.141 at 2016-10-23 23:51:16 +0000
Processing by ApiController#i18n as JSON
Parameters: {"locale"=>"site-pt"}
Rendered app/assets/i18n/site-pt.json (0.1ms)
Completed 200 OK in 35ms (Views: 5.8ms | ActiveRecord: 27.9ms)
Started GET "/assets/fontawesome/fonts/fontawesome-webfont.woff2?v=4.5.0" for 177.207.232.141 at 2016-10-23 23:51:16 +0000
Started GET "/sign_up" for 177.207.232.141 at 2016-10-23 23:51:16 +0000
Processing by Devise::RegistrationsController#new as HTML
[1m[36mSubdomain Load (27.6ms)[0m [1mSELECT "subdomains".* FROM "subdomains" WHERE "subdomains"."address" = $1 LIMIT 1[0m [["address", "yoga"]]
[1m[35mDomain Load (27.5ms)[0m SELECT "domains".* FROM "domains" WHERE "domains"."address" = $1 LIMIT 1 [["address", "smartmarket.io"]]
Rendered devise/registrations/_social.erb (0.5ms)
Rendered devise/registrations/new.html.erb within layouts/application (2.2ms)
Rendered layouts/partials/_topnavbar.html.erb (0.4ms)
Rendered layouts/partials/_sidebar.html.erb (0.1ms)
Rendered layouts/partials/_footer.html.erb (0.0ms)
Rendered layouts/partials/_alerts.erb (0.1ms)
Completed 200 OK in 231ms (Views: 144.7ms | ActiveRecord: 83.0ms)
Here is the user.rb
class User < ActiveRecord::Base
include Userable
# include DeviseTokenAuth::Concerns::User
# Include default devise modules. Others available are:
# :lockable, :timeoutable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable,
:validatable, :omniauthable # , :confirmable
validates :email, uniqueness: true
enum permission: [:guest, :admin]
after_create :create_profile!, :send_welcome_email!
before_validation :set_uid!
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.name = auth.info.name
user.provider = auth.provider
user.uid = auth.uid
user.email = auth.info.email
user.image = auth.info.image
user.password = Devise.friendly_token[0, 20]
end
end
def main_profile
user_main_profile.try :profile
end
private
def set_uid!
self.uid = 'really?'
end
def create_profile!
profile = profiles.create(
name: name,
kind: 'blog'
)
create_user_main_profile(profile_id: profile.id)
end
def send_welcome_email!
UserMailer.delay.welcome(self.id)
end
end
What I can tell is that your INSERT:
[1m[35mSQL (27.9ms)[0m INSERT INTO "users" ("provider", "uid", "name", "email", "image", "encrypted_password", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["provider", "google_oauth2"], ["uid", "really?"], ["name", "Diogo Wernik"], ["email", "diogowernik#gmail.com"], ["image", "https://lh6.googleusercontent.com/-vXjHRteu8BY/AAAAAAAAAAI/AAAAAAAAB3A/_oEJPVq8h8o/photo.jpg"], ["encrypted_password", "$2a$10$6CIsOntiZxoLQfyUTfskiuys3P4u6.M0O4h/4S5zoW7EpN2KgX4Re"], ["created_at", "2016-10-23 23:47:34.023034"], ["updated_at", "2016-10-23 23:47:34.023034"]]
is passing field ["uid", "really?"] when it should be passing ["uid", "110174173081848856467"]
So when the user tries to log via Google, it searches:
SELECT "users".* FROM "users" WHERE "users"."provider" = $1 AND "users"."uid" = $2 ORDER BY "users"."id" ASC LIMIT 1 [["provider", "google_oauth2"], ["uid", "110174173081848856467"]]
Check your user.rb to see how omniauth is getting the variables or edit your post with the content.

403 Forbidden with Doorkeeper, Devise, Rails 5.0.0

I'm trying to get OAuth 2 to work with Rails 5.0.0,
I get a 403 error when test credential with rspec as following.
Can anyone please guide me if I am missing something?
I use the gems:
doorkeeper 3.1.0
postgresql 0.18.4
devise 4.1.1
rspec 3.5.0
credentials_controller.rb:
module Api
module V1
# Credentials Controller
class CredentialsController < ApiController
before_action :doorkeeper_authorize!
respond_to :json
def me
respond_with current_resource_owner
end
end
end
end
credentials_controller_spec.rb:
describe Api::V1::CredentialsController, type: :controller do
describe 'GET #me (integrated)' do
# sample
let!(:application) { Doorkeeper::Application.create!(:name => 'MyApp', :redirect_uri => 'http://app.com') }
let!(:user) { User.create!(:email => 'ax#b.com', :password => 'abc123', :password_confirmation => 'abc123') }
let!(:token) { Doorkeeper::AccessToken.create! :application_id => application.id, :resource_owner_id => user.id }
context 'When responds succeeded' do
subject(:response) { get :me, format: :json, access_token: token.token }
it 'Return 200 status code' do
expect(response.status).to be == 200
end
end
end
end
log
[1m[36mActiveRecord::SchemaMigration Load (1.1ms)[0m [1m[34mSELECT "schema_migrations".* FROM "schema_migrations"[0m
[1m[35m (0.4ms)[0m [1m[35mBEGIN[0m
[1m[35m (0.6ms)[0m [1m[35mSAVEPOINT active_record_1[0m
[1m[36mDoorkeeper::Application Exists (2.4ms)[0m [1m[34mSELECT 1 AS one FROM "oauth_applications" WHERE "oauth_applications"."uid" = $1 LIMIT $2[0m [["uid", "e3f3a2ef90419eee24bfa1655fea0e2c8555a79fd95f94c841baa9fa07d28dfe"], ["LIMIT", 1]]
[1m[35mSQL (1.1ms)[0m [1m[32mINSERT INTO "oauth_applications" ("name", "uid", "secret", "redirect_uri", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id"[0m [["name", "MyApp"], ["uid", "e3f3a2ef90419eee24bfa1655fea0e2c8555a79fd95f94c841baa9fa07d28dfe"], ["secret", "1baa29493585232c23b7d53b418b6bff9df9a5f5f018a47a223f7afa6e678004"], ["redirect_uri", "http://app.com"], ["created_at", 2016-07-06 03:43:01 UTC], ["updated_at", 2016-07-06 03:43:01 UTC]]
[1m[35m (0.2ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
[1m[35m (0.6ms)[0m [1m[35mSAVEPOINT active_record_1[0m
[1m[36mUser Exists (10.7ms)[0m [1m[34mSELECT 1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2[0m [["email", "ax#b.com"], ["LIMIT", 1]]
[1m[35mSQL (1.0ms)[0m [1m[32mINSERT INTO "users" ("email", "encrypted_password", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"[0m [["email", "ax#b.com"], ["encrypted_password", "$2a$11$wclAIfVHRR2rKPPMNY4By.iSEeM.xEt/9xn6ZMdIOXGWKHE8A4Kyy"], ["created_at", 2016-07-06 03:43:02 UTC], ["updated_at", 2016-07-06 03:43:02 UTC]]
[1m[35m (0.2ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
[1m[35m (0.6ms)[0m [1m[35mSAVEPOINT active_record_1[0m
[1m[36mDoorkeeper::Application Load (1.2ms)[0m [1m[34mSELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."id" = $1 LIMIT $2[0m [["id", 88], ["LIMIT", 1]]
[1m[36mDoorkeeper::AccessToken Exists (4.2ms)[0m [1m[34mSELECT 1 AS one FROM "oauth_access_tokens" WHERE "oauth_access_tokens"."token" = $1 LIMIT $2[0m [["token", "2260761b3f5587619ea0944a09623624dbb1dc2d5ed539b705d6334b764a27e2"], ["LIMIT", 1]]
[1m[35mSQL (2.6ms)[0m [1m[32mINSERT INTO "oauth_access_tokens" ("resource_owner_id", "application_id", "token", "created_at") VALUES ($1, $2, $3, $4) RETURNING "id"[0m [["resource_owner_id", 354], ["application_id", 88], ["token", "2260761b3f5587619ea0944a09623624dbb1dc2d5ed539b705d6334b764a27e2"], ["created_at", 2016-07-06 03:43:02 UTC]]
[1m[35m (0.5ms)[0m [1m[35mRELEASE SAVEPOINT active_record_1[0m
DEPRECATION WARNING: ActionController::TestCase HTTP request methods will accept only
keyword arguments in future Rails versions.
Examples:
get :show, params: { id: 1 }, session: { user_id: 1 }
process :update, method: :post, params: { id: 1 }
(called from block (4 levels) in <top (required)> at /Users/yongwoon_kim/Desktop/yongwoon/Source/00_private/ruby/ruby_rails_api_cloud_music/spec/app/controllers/v1/credentials_controller_spec.rb:16)
DEPRECATION WARNING: ActionController::TestCase HTTP request methods will accept only
keyword arguments in future Rails versions.
Examples:
get :show, params: { id: 1 }, session: { user_id: 1 }
process :update, method: :post, params: { id: 1 }
(called from block (4 levels) in <top (required)> at /Users/yongwoon_kim/Desktop/yongwoon/Source/00_private/ruby/ruby_rails_api_cloud_music/spec/app/controllers/v1/credentials_controller_spec.rb:16)
Processing by Api::V1::CredentialsController#me as JSON
Parameters: {"access_token"=>"[FILTERED]"}
[1m[36mDoorkeeper::AccessToken Load (0.2ms)[0m [1m[34mSELECT "oauth_access_tokens".* FROM "oauth_access_tokens" WHERE "oauth_access_tokens"."token" = $1 LIMIT $2[0m [["token", "2260761b3f5587619ea0944a09623624dbb1dc2d5ed539b705d6334b764a27e2"], ["LIMIT", 1]]
Filter chain halted as :doorkeeper_authorize! rendered or redirected
Completed 403 Forbidden in 15ms (ActiveRecord: 0.2ms)
[1m[35m (0.3ms)[0m [1m[31mROLLBACK[0m

Rails Ajax redirect, doesn`t change the view

Hi I have a character_form with js: true
This are my controller actions:
def new
#user = User.find(params[:user_id])
#character = Character.new
#clan = Clan.where(name: params[:clan]).take || Clan.where(name: "Feniks").take
#families = #clan.families
respond_to do |format|
format.js
format.html
end
end
def create
#user = User.find(params[:user_id])
#character = #user.characters.new(character_params)
if #character.save
redirect_to current_user
else
#clan = Clan.where(name: params[:character][:clan]).take
#families = #clan.families
render :new
end
end
And user#show action:
def show
#user = User.find(params[:id])
#characters = #user.characters.all.order(:family, :name)
end
After I submit the character_form the server shows:
Started POST "/users/1/characters" for 127.0.0.1 at 2015-11-17 01:55:20 -0400
Processing by CharactersController#create as JS
Parameters: {"utf8"=>"✓", "character"=>{"name"=>"Q mlak", "clan"=>"Feniks", "family"=>"Agasha", "desc"=>"alalalal"}, "commit"=>"Zapisz", "user_id"=>"1"}
User Load (5.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
(0.6ms) BEGIN
SQL (4.4ms) INSERT INTO "characters" ("name", "clan", "desc", "family", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id" [["name", "Q mlak"], ["clan", "Feniks"], ["desc", "alalalal"], ["family", "Agasha"], ["user_id", 1], ["created_at", "2015-11-17 05:55:20.778436"], ["updated_at", "2015-11-17 05:55:20.778436"]]
(30.4ms) COMMIT
Redirected to http://localhost:3000/users/1
Completed 302 Found in 52ms (ActiveRecord: 40.7ms)
Started GET "/users/1" for 127.0.0.1 at 2015-11-17 01:55:20 -0400
Processing by UsersController#show as JS
Parameters: {"id"=>"1"}
User Load (2.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
(0.3ms) SELECT COUNT(*) FROM "characters" WHERE "characters"."user_id" = $1 [["user_id", 1]]
Character Load (0.2ms) SELECT "characters".* FROM "characters" WHERE "characters"."user_id" = $1 ORDER BY "characters"."family" ASC, "characters"."name" ASC [["user_id", 1]]
Rendered users/show.html.erb within layouts/application (8.3ms)
Rendered layouts/_header.html.erb (4.1ms)
Rendered layouts/_gretel.html.erb (0.9ms)
Rendered layouts/_footer.html.erb (0.4ms)
Completed 200 OK in 423ms (Views: 415.9ms | ActiveRecord: 3.1ms)
I don`t have create.js.erb nor show.js.erb files.
My problem is that the view in the browser doesn't fallow the server. I know that ajax fakes the screen. My goal is to redirect to current_user path as html after form is submitted.

Rails 4: Double request/response/select/insert

in my rails 4 app I noticed, that when I create new comment, every request/response are doubles. anybody know why?
I'm using ajax
this is my logs:
Started POST "/comments" for 127.0.0.1 at 2015-03-25 21:07:06 +0400
Started POST "/comments" for 127.0.0.1 at 2015-03-25 21:07:06 +0400
Processing by CommentsController#create as JS
Processing by CommentsController#create as JS
Parameters: {"utf8"=>"✓", "recipe_id"=>"1", "comment"=>"llkl;kl;k;l", "commit"=>"Add Comment"}
Parameters: {"utf8"=>"✓", "recipe_id"=>"1", "comment"=>"llkl;kl;k;l", "commit"=>"Add Comment"}
Recipe Load (0.1ms) SELECT "recipes".* FROM "recipes" WHERE "recipes"."id" = ? LIMIT 1 [["id", 1]]
Recipe Load (0.1ms) SELECT "recipes".* FROM "recipes" WHERE "recipes"."id" = ? LIMIT 1 [["id", 1]]
User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
(0.1ms) begin transaction
(0.1ms) begin transaction
SQL (0.2ms) INSERT INTO "comments" ("commentable_id", "commentable_type", "comment", "user_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["commentable_id", 1], ["commentable_type", "Recipe"], ["comment", "llkl;kl;k;l"], ["user_id", 1], ["created_at", "2015-03-25 17:07:06.221648"], ["updated_at", "2015-03-25 17:07:06.221648"]]
SQL (0.2ms) INSERT INTO "comments" ("commentable_id", "commentable_type", "comment", "user_id", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?) [["commentable_id", 1], ["commentable_type", "Recipe"], ["comment", "llkl;kl;k;l"], ["user_id", 1], ["created_at", "2015-03-25 17:07:06.221648"], ["updated_at", "2015-03-25 17:07:06.221648"]]
(17.8ms) commit transaction
(17.8ms) commit transaction
Comment Load (2.0ms) SELECT "comments".* FROM "comments" WHERE "comments"."commentable_id" = ? AND "comments"."commentable_type" = ? ORDER BY created_at DESC LIMIT 15 OFFSET 0 [["commentable_id", 1], ["commentable_type", "Recipe"]]
Comment Load (2.0ms) SELECT "comments".* FROM "comments" WHERE "comments"."commentable_id" = ? AND "comments"."commentable_type" = ? ORDER BY created_at DESC LIMIT 15 OFFSET 0 [["commentable_id", 1], ["commentable_type", "Recipe"]]
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
Rendered recipes/_comments.html.erb (6.2ms)
Rendered recipes/_comments.html.erb (6.2ms)
Rendered comments/create.js.erb (15.3ms)
Rendered comments/create.js.erb (15.3ms)
Completed 200 OK in 54ms (Views: 16.4ms | ActiveRecord: 20.3ms)
Completed 200 OK in 54ms (Views: 16.4ms | ActiveRecord: 20.3ms)

Resources