I have a view page that will randomly turn into a blank white page after I have visited it a few times. If I change something in the view, it turns back to normal temporarily, but then after a few more page visits, the page turns white again. Also, it only happens in Safari. Here is the controller action for the page:
class ProjectsController < ApplicationController
def show_current_projects_to_freelancer
if current_user.type == 'Student'
#projects = current_user.projects
#schedules = current_user.projects.collect {|project| project.schedule}
else
redirect_to applicants_path, notice: 'Only Freelancers have access to this page.'
end
end
end
There are two models: Schedule and Project. Schedule belongs_To Project and Project has_one schedule. The routes for schedule and Project are nested like this:
get 'projects/current', to: 'projects#show_current', as: :current_freelancer_projects
resources :projects do
resources :schedules
end
I've changed my view several times. This happens regardless of whether there is content in the view or no content. Here is what the view looks like now:
<div style="color: black;">
<h3>Current freelancer Projects</h3>
<table>
<tr>
<td>Project Name</td>
<td>Employer Name</td>
<td>Date of Bid</td>
<td>rating</td>
<td>Bid</td>
<td>Tags</td>
<td>Make Schedule</td>
</tr>
<% #projects.each do |project| %>
<tr>
<td><%= project.title %></td>
<td><%= project.employer.email %></td>
<td>date</td>
<td>rating</td>
<td>bid</td>
<td>tags</td>
<td><%= link_to 'Create Schedule', new_project_schedule_path(project.id, Schedule.new) %></td>
</tr>
<% end %>
</table>
</div>
I can't imagine what is causing this. I know it has to be independent from the view because no matter how i change the view it still happens. Does anyone have any ideas?
Here are the logs when the page does not show up. When the page does show up, its too long.
Started GET "/current" for 127.0.0.1 at 2013-11-22 17:08:18 -0500
Started GET "/current" for 127.0.0.1 at 2013-11-22 17:08:18 -0500
ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by ProjectsController#show_current_projects_to_freelancer as HTML
Processing by ProjectsController#show_current_projects_to_freelancer as HTML
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 226 ORDER BY "users"."id" ASC LIMIT 1
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 226 ORDER BY "users"."id" ASC LIMIT 1
Project Load (3.3ms) SELECT "projects".* FROM "projects" WHERE "projects"."student_id" = $1 [["student_id", 226]]
Project Load (3.3ms) SELECT "projects".* FROM "projects" WHERE "projects"."student_id" = $1 [["student_id", 226]]
Employer Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 202]]
Employer Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 202]]
Employer Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 201]]
Employer Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 201]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 201]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 201]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 201]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 201]]
Rendered projects/show_current_projects_to_freelancer.html.erb within layouts/application (97.3ms)
Rendered projects/show_current_projects_to_freelancer.html.erb within layouts/application (97.3ms)
(0.9ms) SELECT COUNT(*) FROM "relationships" WHERE "relationships"."student_id" = $1 AND "relationships"."state" = 'active' [["student_id", 226]]
(0.9ms) SELECT COUNT(*) FROM "relationships" WHERE "relationships"."student_id" = $1 AND "relationships"."state" = 'active' [["student_id", 226]]
Profile Load (1.0ms) SELECT "profiles".* FROM "profiles" WHERE "profiles"."user_id" = $1 ORDER BY "profiles"."id" ASC LIMIT 1 [["user_id", 226]]
Profile Load (1.0ms) SELECT "profiles".* FROM "profiles" WHERE "profiles"."user_id" = $1 ORDER BY "profiles"."id" ASC LIMIT 1 [["user_id", 226]]
Rendered layouts/_ssi_header_inner.html.erb (69.1ms)
Rendered layouts/_ssi_header_inner.html.erb (69.1ms)
Rendered layouts/_ssi_footer.html.erb (0.3ms)
Rendered layouts/_ssi_footer.html.erb (0.3ms)
Completed 200 OK in 547ms (Views: 384.9ms | ActiveRecord: 17.2ms)
Completed 200 OK in 547ms (Views: 384.9ms | ActiveRecord: 17.2ms)
The problem was the cache. By disabling the cache, I was able to fix the problem.
Looks like a WebKit bug; it's happening with a lot of people even in iOS. https://bugs.webkit.org/show_bug.cgi?id=32829
Actually the linked Webkit bugreport is wrong, because it refers to a Server sending a 304 for an unconditional request, so this is actually bad behavior of the Server and no Webkit bug.
The Bug that shows up in Safari is that it sends a conditional request, the server responds correctly with a 304 and then Safari shows a white page, probably due to invalid Cache.
And I doubt this is a Webkit bug after all, since no other Browser is affected, at least what I managed to research so far I could only reproduce this in Safari.
I filed a radar on Apples Bugtracker (rdar://19074069), but if anyone can reproduce this with the Webkit browser, then this is more likely a Webkit bug, but I weren't able to do so.
Related
I am doing a rake task to sync data from rails app to solr
I use:
Job.all to get all the records and process them afterwards.But what if in Job has millions of records. As far as I know the all method will save all records to RAM, which definitely affects performance. Is there any other way to process all records without using all method?
Look at the find_in_batches, this will not load all the records at once.
By default it will load the 1000 rows and also helps to reduce memory consumption.
2.5.1 :013 > User.find_in_batches do |group, batch|
2.5.1 :014 > puts "Processing group ##{batch}"
2.5.1 :015?> end
User Load (7.5ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT $1 [["LIMIT", 1000]]
Processing group ##<User:0x00005596f8ef44c8>
User Load (5.9ms) SELECT "users".* FROM "users" WHERE "users"."id" > $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 1002], ["LIMIT", 1000]]
Processing group ##<User:0x00005596f908e900>
User Load (5.0ms) SELECT "users".* FROM "users" WHERE "users"."id" > $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 2002], ["LIMIT", 1000]]
Processing group ##<User:0x00007f36a4f1a428>
User Load (6.7ms) SELECT "users".* FROM "users" WHERE "users"."id" > $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 3004], ["LIMIT", 1000]]
Processing group ##<User:0x00007f36a4b82590>
I'm using will_paginate to paginate posts within a group.
A group might have many posts and I don't want to show all posts at once.
For some strange reason I noticed that a lot of posts are deleted from the database when I do #group.posts = paginated_posts as displayed in * groups_controller*.
I'm not doing save on #group, why are the posts deleted?
Tests first
69 it "Pagination – get one group and its posts" do
70 10.times { Fabricate(:post, group: #group, user: #user) }
71 puts "POST COUNT BEFORE #{#group.posts.count}"
72 # byebug
73 get group_path(#group, posts_per_page: 3)
74 puts "POST COUNT AFTER #{#group.posts.count}"
75 expect(response).to have_http_status(200)
76 expect(#group).to be_present
77 end
Output from the test
Groups
GET /group/:group_id?posts_per_page=10&posts_page=2
POST COUNT BEFORE 12
POST COUNT AFTER 3
groups_controller.rb
9 def show
10 paginated_posts = #group.posts.paginate(
11 page: params[:posts_page],
12 per_page: params[:posts_per_page] || 100000,
13 )
14 #group.posts = paginated_posts
15 render json: #group
16 end
The log
(0.3ms) RELEASE SAVEPOINT active_record_1
Started GET "/groups/33?posts_per_page=3" for 127.0.0.1 at 2018-09-18 12:52:13 +0000
Processing by GroupsController#show as HTML
Parameters: {"posts_per_page"=>"3", "id"=>"33"}
User Load (2.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", "78913bd2-4c72-4c73-ba75-421e154c830b"], ["LIMIT", 1]]
Group Load (1.4ms) SELECT "groups".* FROM "groups" WHERE "groups"."id" = $1 LIMIT $2 [["id", 33], ["LIMIT", 1]]
Post Load (2.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."group_id" = $1 LIMIT $2 OFFSET $3 [["group_id", 33], ["LIMIT", 3], ["OFFSET", 0]]
Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE "posts"."group_id" = $1 [["group_id", 33]]
(0.4ms) SAVEPOINT active_record_1
Comment Load (0.5ms) SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = $1 [["post_id", 156]]
PostImage Load (0.3ms) SELECT "post_images".* FROM "post_images" WHERE "post_images"."post_id" = $1 [["post_id", 156]]
Post Destroy (0.3ms) DELETE FROM "posts" WHERE "posts"."id" = $1 [["id", 156]]
Comment Load (0.3ms) SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = $1 [["post_id", 157]]
PostImage Load (0.3ms) SELECT "post_images".* FROM "post_images" WHERE "post_images"."post_id" = $1 [["post_id", 157]]
Post Destroy (0.3ms) DELETE FROM "posts" WHERE "posts"."id" = $1 [["id", 157]]
Comment Load (0.3ms) SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = $1 [["post_id", 158]]
#group.posts = ... doesn't work the way you think it does. If you have a one-to-many relationship and you assign an array of associated records to the existing group object, the records set and remove the group.id foreign key immediately. No save is required.
So when you do
#group.posts = paginated_posts
The paginated posts are assigned to the association and all other records in the association are removed from the association. Instantly. They're not necessarily deleted, but they no longer belong to #post
You may want to change your #to_json ... perhaps add
attr_accessor :page_of_posts
And then in your controller
#group.page_of_posts = paginated_posts
And ensure page_of_posts is what's rendered in the json. Others may suggest a better way.
I have a rails app and I'd like to extract 2 different ids from this url:
http://localhost:3000/shopping/suppliers/2/products/1
Looking at the development.log it seems like both values are there.
I'm wondering how I can expose these params to the controller, is it just params[:supplier_id] and params[:id]?
Started GET "/shopping/suppliers/2/products/1" for 127.0.0.1 at 2016-04-22 18:28:19 +1000
Processing by Shopping::ProductsController#show as HTML
Parameters: {"supplier_id"=>"2", "id"=>"1"}
Product Load (30.1ms) SELECT "products".* FROM "products" WHERE "products"."permalink" = $1 ORDER BY "products"."id" ASC LIMIT 1 [["permalink", "1"]]
Product Load (0.8ms) SELECT "products".* FROM "products" WHERE "products"."id" = $1 LIMIT 1 [["id", 1]]
User Load (19.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
CACHE (0.0ms) SELECT "products".* FROM "products" WHERE "products"."permalink" = $1 ORDER BY "products"."id" ASC LIMIT 1 [["permalink", "1"]]
CACHE (0.0ms) SELECT "products".* FROM "products" WHERE "products"."id" = $1 LIMIT 1 [["id", "1"]]
Rendered shopping/products/show.html.haml within layouts/mdl (0.3ms)
Rendered shared/_meta_data.html.haml (0.8ms)
Rendered shared/_top_cart.html.haml (0.1ms)
Rendered shared/_compact_menu.html.haml (4.5ms)
Completed 200 OK in 109ms (Views: 46.2ms | ActiveRecord: 50.8ms)
Yes, you should be able to access your values with those keys:
params[:supplier_id]
params[:id]
It is wierd why you have not tried your own suggestion before posting your question. :)
I have a table subscription with a column status. In my subscriptions controller I have a method accept_player that is supposed to update the subscription.status to "confirmed!"
def accept_player
#subscription = Subscription.find(params[:subscription_id_accept_player])
#subscription.status = "confirmed!"
#subscription.save
authorize #subscription
redirect_to tournament_subscriptions_path(#subscription.tournament)
end
unfortunately every time I try to trigger that method, a rollback seem to take place:
Started POST "/accept_player/39" for ::1 at 2015-07-08 22:01:21 +0100
ActiveRecord::SchemaMigration Load (12.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
/Users/davidgeismar/code/davidgeismar/tennis-match/app/controllers/subscriptions_controller.rb:141: warning: duplicated key at line 155 ignored: "CardType"
Processing by SubscriptionsController#accept_player as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"aas8OPHBpvPwNbbmx/SVipsRM+eKo63nuVilMroxKcU9HRVonjSqEuH7aLY91gFi9PHMUsUqRqk7qhnv2m4L/A==", "subscription_id_accept_player"=>"39", "commit"=>"Confirmer ce Joueur", "subscription_id"=>"39"}
User Load (13.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 2]]
Subscription Load (11.6ms) SELECT "subscriptions".* FROM "subscriptions" WHERE "subscriptions"."id" = $1 LIMIT 1 [["id", 39]]
(5.7ms) BEGIN
Subscription Exists (0.8ms) SELECT 1 AS one FROM "subscriptions" WHERE ("subscriptions"."user_id" = 20 AND "subscriptions"."id" != 39 AND "subscriptions"."tournament_id" = 9) LIMIT 1
(12.6ms) ROLLBACK
Tournament Load (2.4ms) SELECT "tournaments".* FROM "tournaments" WHERE "tournaments"."id" = $1 LIMIT 1 [["id", 9]]
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 2]]
Redirected to http://localhost:3000/tournaments/9/subscriptions
Completed 302 Found in 246ms (ActiveRecord: 79.7ms)
Any ideas about what might be going wrong here ?
This code:
authorize #subscription
is probably causing the rollback. If you're in dev mode, just comment it out, reload!, and try to manually add a record and see if that's the cause.
I'm building an Rails 4 app with the authentication gem 'clearance'. I'm kind of stuck with the following problem:
When an user forgets his/her password and would like to set a new password, the user is not found. (but exist in DB), this is the server log:
Started PUT "/passwords/1?token=[FILTERED]" for 127.0.0.1 at 2013-08-10 21:00:58 +0200
Processing by PasswordsController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "password_reset"=>"[FILTERED]", "token"=>"[FILTERED]", "id"=>"1"}
User Load (1.1ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL AND "users"."confirmation_token" = 'bcc6a5b49bc64628eff15bf92761fe1775ef252c' LIMIT 1
Rendered passwords/new.html.slim within layouts/application (0.9ms)
Rendered partials/_favicon_styles.html.slim (0.4ms)
User Load (0.9ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
Rendered partials/_navigation.html.slim (11.2ms)
Rendered partials/_notification.html.slim (0.1ms)
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
Rendered partials/_footer.html.slim (1.0ms)
Filter chain halted as :forbid_non_existent_user rendered or redirected
Completed 200 OK in 38ms (Views: 33.0ms | ActiveRecord: 2.3ms)
But when a user is logged in, he or she can change password and also login works normally ..
I think the problem is in the query, I am sending the id with the form, but when the id reaches the query it says IS NULL. But I've struggled with it for hours, but can't find the solution.
Also is the 7 times request for cache a problem?
Thanks in advance!
Update
Changed the strong parameters and the 'find_user_by_id_and_confimatrion_token' method as followed:
def find_user_by_id_and_confirmation_token
Clearance.configuration.user_model.
find_by_id_and_confirmation_token params[:**id**], params[:token].to_s
end
This was :user_id, this is not the name of the params.
def password_reset_params
# if params.has_key? :user
# ActiveSupport::Deprecation.warn %{Since locales functionality was added, accessing params[:user] is no longer supported.}
# params[:user][:password]
# else
# params[:password_reset][:password]
# end
params.require(:password_reset).permit(:password_reset, :password, :token, :id)
end
But this throws in another error:
Started PUT "/passwords/1?token=[FILTERED]" for 127.0.0.1 at 2013-08-11 16:31:20 +0200
Processing by PasswordsController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "password_reset"=>" [FILTERED]", "token"=>"[FILTERED]", "id"=>"1"}
User Load (1.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 AND "users"."confirmation_token" = 'd892a4698f5eff29e34378716ebd46414ad6e8cf' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 AND "users"."confirmation_token" = 'd892a4698f5eff29e34378716ebd46414ad6e8cf' LIMIT 1
(0.4ms) BEGIN
User Exists (1.0ms) SELECT 1 AS one FROM "users" WHERE ("users"."email" = 'user#test.nl' AND "users"."id" != 1) LIMIT 1
(0.4ms) ROLLBACK
Rendered passwords/edit.html.slim within layouts/application (1.2ms)
Rendered partials/_favicon_styles.html.slim (0.3ms)
User Load (0.9ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
Rendered partials/_navigation.html.slim (4.7ms)
Rendered partials/_notification.html.slim (0.1ms)
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
Rendered partials/_footer.html.slim (0.4ms)
Completed 200 OK in 112ms (Views: 12.5ms | ActiveRecord: 4.1ms)
It says that the user already exists, and rollback the changes. Because this is an update, the user must exist.
Update 2
I'm still trying to fix this issue, here the difference between a logged in user who's editing their password, and via password forget method (not logged in)
Logged in user changing password
Started PATCH "/admin/users/1" for 127.0.0.1 at 2013-08-13 16:12:07 +0200
Processing by Admin::UsersController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "user"=>{"password"=>" [FILTERED]", "password_confirmation"=>"[FILTERED]"}, "id"=>"1"}
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = 'f1078c2b74f6b3b3c9950b87a5b927db3f2bffcd' LIMIT 1
User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1(0.4ms)
BEGIN
User Exists (1.0ms) SELECT 1 AS one FROM "users" WHERE ("users"."email" = 'info#netventief.nl' AND "users"."id" != 1) LIMIT 1
SQL (1.6ms) UPDATE "users" SET "encrypted_password" = $1, "updated_at" = $2 WHERE "users"."id" = 1 [["encrypted_password", "$2a$10$F4p6N0va/TY2nKOiXOSQ7e23NnHPyDytQZ6EvhtGd7FJ2oTMVFbSS"], ["updated_at", Tue, 13 Aug 2013 16:12:07 CEST +02:00]](12.6ms)
COMMIT
Rendered admin/users/edit.html.slim within layouts/application (8.7ms)
Rendered partials/_favicon_styles.html.slim (0.3ms)
Rendered partials/_olderbrowser.html (0.0ms)
Rendered partials/_navigation.html.slim (2.6ms)
Rendered partials/_notification.html.slim (0.1ms)
Rendered partials/_footer.html.slim (0.1ms)
Completed 200 OK in 167ms (Views: 23.0ms | ActiveRecord: 17.3ms)
User who is forgotten the password and would enter a new password
Started PUT "/passwords/1?token=[FILTERED]" for 127.0.0.1 at 2013-08-13 16:58:45 +0200
Processing by PasswordsController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "user"=>{"password"=>"[FILTERED]"}, "token"=>"[FILTERED]", "id"=>"1"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 AND "users"."confirmation_token" = 'b198361b098c1bf110a2171dd7f00258d9ca9240' LIMIT 1
CACHE
(0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 AND "users"."confirmation_token" = 'b198361b098c1bf110a2171dd7f00258d9ca9240' LIMIT 1
(0.3ms)BEGIN
User Exists (0.5ms) SELECT 1 AS one FROM "users" WHERE ("users"."email" = 'info#netventief.nl' AND "users"."id" != 1) LIMIT 1
(0.2ms) ROLLBACK
Rendered passwords/edit.html.slim within layouts/application (1.4ms)
Rendered partials/_favicon_styles.html.slim (0.3ms)
Rendered partials/_olderbrowser.html (0.0ms)
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
Rendered partials/_navigation.html.slim (5.0ms)
Rendered partials/_notification.html.slim (0.1ms)
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '' LIMIT 1
Rendered partials/_footer.html.slim (0.5ms)
Completed 200 OK in 102ms (Views: 14.7ms | ActiveRecord: 2.0ms)
Still expect the Put/Patch method and all the cache alerts. This seems pretty the same to me .. I have tried to use the patch http method, but it didn't help.
Update 3
Also my controller code, its pretty much the same as Clearance::PasswordsController. Removed methods that are not called by my problem.
require 'active_support/deprecation'
class PasswordsController < ApplicationController
skip_before_filter :authorize, :only => [:create, :edit, :new, :update]
before_filter :forbid_missing_token, :only => [:edit, :update]
before_filter :forbid_non_existent_user, :only => [:edit, :update]
def edit
#user = find_user_for_edit
render :template => 'passwords/edit'
end
def update
#user = find_user_for_update
if #user.update_attributes( password: password_reset_params )
sign_in #user
redirect_to url_after_update
else
flash_failure_after_update
render :template => 'passwords/edit'
end
end
private
def password_reset_params
if params.has_key? :user
ActiveSupport::Deprecation.warn %{Since locales functionality was added, accessing params[:user] is no longer supported.}
params[:user][:password]
else
params[:password_reset][:password]
end
end
def find_user_by_id_and_confirmation_token
Clearance.configuration.user_model.
find_by_id_and_confirmation_token params[:id], params[:token].to_s
end
def find_user_for_edit
find_user_by_id_and_confirmation_token
end
def find_user_for_update
find_user_by_id_and_confirmation_token
end
def forbid_missing_token
if params[:token].to_s.blank?
flash_failure_when_forbidden
render :template => 'passwords/new'
end
end
def forbid_non_existent_user
unless find_user_by_id_and_confirmation_token
flash_failure_when_forbidden
render :template => 'passwords/new'
end
end
end
You should track down where the following SQL query is being triggered from:
User Exists (0.5ms) SELECT 1 AS one FROM "users" WHERE ("users"."email" = 'info#netventief.nl' AND "users"."id" != 1) LIMIT 1
This is the line that is causing your save to fail. My guess is that you have a validation or some other callback on your User model that is firing when you are calling #user.update_attributes. The validation/callback is failing, which is causing the save to fail.
This is the line that is causing your save to fail. My guess is that you have a validation or some other callback on your User model that is firing when you are calling #user.update_attributes. The validation/callback is failing, which is causing the save to fail.