devise

Couldn't find User with 'id'=sign_out

大兔子大兔子 提交于 2020-01-04 05:16:13
问题 I'm using devise in rails and I'm unable to logout of my user right now. When I use the users/log_out page, it gives the following error: ActiveRecord::RecordNotFound in UsersController#show Couldn't find User with 'id'=sign_out Anyway, here is my users controller: class UsersController < ApplicationController def new @user = User.new end def create @user = User.new(user_params) if @user.save redirect_to users_path else render 'new' end end def index @users=User.all end def edit @user = User

Couldn't find User with 'id'=sign_out

匆匆过客 提交于 2020-01-04 05:16:07
问题 I'm using devise in rails and I'm unable to logout of my user right now. When I use the users/log_out page, it gives the following error: ActiveRecord::RecordNotFound in UsersController#show Couldn't find User with 'id'=sign_out Anyway, here is my users controller: class UsersController < ApplicationController def new @user = User.new end def create @user = User.new(user_params) if @user.save redirect_to users_path else render 'new' end end def index @users=User.all end def edit @user = User

Devise authentication when accessing directly to a pdf file unauthenticated

末鹿安然 提交于 2020-01-04 04:19:26
问题 I have a problem when trying to see a .pdf file (generated with PDFKit) unauthenticated, just going directly from a given url host/.../profile.pdf . I, as expected, am asked to enter the credentials as shown in the image (Not in the users/sign_in path): I enter the correct credentials, the box goes up and down and asks for the credentials again. It could seem like the user or password are wrong, but they aren't. The relevant code from the controller is here: class Entrepreneur:

Getting email back from Twitter Oauth with Devise and Rails

我的梦境 提交于 2020-01-04 04:06:27
问题 I've set up a basic rails application to use twitter oauth gem and devise and have been able to log in a user. However, my problem is I've now got my app white-listed and I would like to get a user's email back in the response. I've followed all necessary steps on the twitter side (setting necessary permissions, URLS, and reset keys) and have tried passing both include_email=true and include_email=email as a params when I initiate the oauth sequence. I feel like I've read and re-read the docs

custom sign in for devise

倖福魔咒の 提交于 2020-01-04 02:46:09
问题 Now I am using the devise gem, and after successful authorization it redirects user to the root page. How to modify sign_in action to return json array like this: {"auth_result":"1"} instead of redirect? Is it possible? I haven't found recipes for these in devise wiki. 回答1: Devise currently does not handle JSON responses - see the issue on github. Therefore you would have to create a custom sessions_controller to handle your response. Take a look at the implementation on github to get an idea

Set user time zone dynamically with devise

时光毁灭记忆、已成空白 提交于 2020-01-03 18:04:34
问题 I've built a rails app that helps parents keep track of their infants’ sleep. For it to work properly I've had to support different time zones. To avoid annoying the user with time zones, I've created a little javascript that adds a hidden field to the login form, including the timezone offset. Here's the code var timeZoneField = $("input[name='user_tz_offset']"); if (timeZoneField.length) { var browserDate = new Date(); var timeZoneOffsetSeconds = (browserDate.getTimezoneOffset() * 60) * -1;

Any Alternate method for Class Casting

本秂侑毒 提交于 2020-01-03 15:22:34
问题 Following statement is not executing on some devices. AddEvent act1 = (AddEvent) getLocalActivityManager().getCurrentActivity(); Is there any alternate method for above statement. On some devices it works fine but on other devices it gives exception. Edit: My application is developed in tab. OnActivity results is used for getting picture from camera activity. Dont know where the resides but when I puts the above statement in try catch then no force close occurs and exception is shown there.

Any Alternate method for Class Casting

非 Y 不嫁゛ 提交于 2020-01-03 15:21:26
问题 Following statement is not executing on some devices. AddEvent act1 = (AddEvent) getLocalActivityManager().getCurrentActivity(); Is there any alternate method for above statement. On some devices it works fine but on other devices it gives exception. Edit: My application is developed in tab. OnActivity results is used for getting picture from camera activity. Dont know where the resides but when I puts the above statement in try catch then no force close occurs and exception is shown there.

How to generate the password in PHP as it did by Devise Gem in Ruby on Rails

独自空忆成欢 提交于 2020-01-03 11:28:06
问题 I'm renewing a website from Ruby on Rails to PHP. I need to generate the passwords which are generated by Devise Gem in Ruby on Rails. I have to know what is the hashing method for password to create same method with PHP. but it's not easy to find that codes inside the Ruby on Rails as a beginner. If somebody know where should I check to find it, please help me. These two are all what I found: 1) The configuration of encryptor is disabled in devise.rb like below: # config.encryptor = :sha1 2)

Rails Devise Polymorphic - Get Render Partial Using Ajax

☆樱花仙子☆ 提交于 2020-01-03 10:05:10
问题 I have implement devise registration with multiple model from this answer. This tuts get params user_type from path. I want to change this with select user_type . So a param user_type will get when I select a value on select_tag . I have some code looks like : routes.rb namespace :cp do devise_scope :user do match '/add_user' => 'registrations#new' match '/select/admin' => 'registrations#selectuser', :user => { :usertype => 'admin' } match '/select/player' => 'registrations#selectuser', :user