devise

Postgres: prepared statement already exists

一个人想着一个人 提交于 2020-01-02 07:21:11
问题 I use Devise for authentication in my Rails API app. Sometimes I see following error in the logs: ActiveRecord::StatementInvalid: PGError: ERROR: prepared statement "a3926" already exists: UPDATE "users" SET "current_sign_in_at" = $1, "last_sign_in_at" = $2, "sign_in_count" = $3, "updated_at" = $4 WHERE "users"."id" = 12345 The error is coming out of Devise: def update_tracked_fields!(request) old_current, new_current = self.current_sign_in_at, Time.now.utc self.last_sign_in_at = old_current

rake db:migrate error tables

耗尽温柔 提交于 2020-01-02 07:06:40
问题 I am trying to run rake db:migrate and am receiving an error in the console. It seems as though I am creating a table that already exists, yet I don't know how to remove the old table, or reset the db to start fresh. I don't have any users so erasing or starting from fresh won't be an issue. create_table(:users) rake aborted! StandardError: An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "users" already exists: CREATE TABLE "users" ("id" INTEGER

How to configure time out using devise?

岁酱吖の 提交于 2020-01-02 03:23:08
问题 Model: devise :database_authenticatable, :registerable,:timeoutable, :recoverable, :rememberable, :trackable, :validatable,:timeout_in => 10.seconds development.rb: config.timeout_in = 10.seconds devise.rb: config.timeout_in = 10.seconds 回答1: Are you expecting the page to refresh and show you a login page again? If so, that's not how the timeoutable feature works. If you're expecting it to present you with the login page when you refresh, remove the timeout part from your model and put the

NameError (undefined local variable or method `devise_parameter_sanitizer'

为君一笑 提交于 2020-01-01 23:54:11
问题 I'm using devise for user authentication. However, when a user tries to create an account I am getting this error: NameError (undefined local variable or method `devise_parameter_sanitizer' This is what my devise registrations controller looks like: def sign_up_params devise_parameter_sanitizer.for(:sign_up) end Any ideas? Thanks in advance 回答1: try to use rails4 branch gem 'devise', github: 'plataformatec/devise', branch: 'rails4' 回答2: Looking at the devise open issues on Github i found this

Rails Devise, how to skip the confirmation email but still generate a confirmation token?

余生长醉 提交于 2020-01-01 11:04:08
问题 I'm using user.skip_confirmation! To skip the devise email confirmation when a new user is added by an existing user. The problem with the skip_confirmation is that it does not generate a confirmation token. I want to manually send a confirmation email which means I need a confirmation token. How can I skip the devise confirmation email yet still generate a confirmaton_token to allow me to manually send a custom confirmation email to added users? Thanks 回答1: See confirmable.rb. In particular,

Rails Devise, how to skip the confirmation email but still generate a confirmation token?

旧街凉风 提交于 2020-01-01 11:03:53
问题 I'm using user.skip_confirmation! To skip the devise email confirmation when a new user is added by an existing user. The problem with the skip_confirmation is that it does not generate a confirmation token. I want to manually send a confirmation email which means I need a confirmation token. How can I skip the devise confirmation email yet still generate a confirmaton_token to allow me to manually send a custom confirmation email to added users? Thanks 回答1: See confirmable.rb. In particular,

How to get CSRF token with rails3.2.x, before sending restful POST/PUT API, without any form/UI from server side?

时光怂恿深爱的人放手 提交于 2020-01-01 11:03:06
问题 I know rails provided CSRF protection by default from rails3. but my web application is a single page application, and all communication depend on ajax. So, how can I get CSRF token from server before each ajax calling? or what I can do is just take off CSRF protection, right? NOTE: we don't use any rails view to produce the web page, even the homepage, so the solution to put "<%= csrf_meta_tag %> " in .html or .erb is invalid ., we use javascript framework within one page. my env: rails3.2.3

How to get CSRF token with rails3.2.x, before sending restful POST/PUT API, without any form/UI from server side?

半世苍凉 提交于 2020-01-01 11:02:58
问题 I know rails provided CSRF protection by default from rails3. but my web application is a single page application, and all communication depend on ajax. So, how can I get CSRF token from server before each ajax calling? or what I can do is just take off CSRF protection, right? NOTE: we don't use any rails view to produce the web page, even the homepage, so the solution to put "<%= csrf_meta_tag %> " in .html or .erb is invalid ., we use javascript framework within one page. my env: rails3.2.3

Rails Devise, how to skip the confirmation email but still generate a confirmation token?

丶灬走出姿态 提交于 2020-01-01 11:02:02
问题 I'm using user.skip_confirmation! To skip the devise email confirmation when a new user is added by an existing user. The problem with the skip_confirmation is that it does not generate a confirmation token. I want to manually send a confirmation email which means I need a confirmation token. How can I skip the devise confirmation email yet still generate a confirmaton_token to allow me to manually send a custom confirmation email to added users? Thanks 回答1: See confirmable.rb. In particular,

Rails error resource_name - devise help routing and rendering

懵懂的女人 提交于 2020-01-01 09:56:14
问题 I am trying to render the login view for the Devise gem but I get an error, below is the code I currently have: This is my views/users/shared/_links.html.erb : <%- if controller_name != 'sessions' %> <%= link_to "Sign in", new_session_path(resource_name) %><br /> <% end -%> <%- if devise_mapping.registerable? && controller_name != 'registrations' %> <%= link_to "Sign up", new_registration_path(resource_name) %><br /> <% end -%> <%- if devise_mapping.recoverable? && controller_name !=