devise

Testing models with RSpec using devise

对着背影说爱祢 提交于 2020-01-06 04:31:22
问题 I am using devise for authentication in my rails app and I'm unable to test any model with RSpec. Controller specs work fine, but I'm unable to make model specs work. I am getting this error: Failures: 1) Group should create new group Failure/Error: Unable to find matching line from backtrace NoMethodError: undefined method `env' for nil:NilClass # /home/hrvoje/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/whiny_nil.rb:48:in `method_missing' # /home/hrvoje/.rvm/gems

what is recommended for handling password for new Facebook signed in users?

别来无恙 提交于 2020-01-06 02:59:07
问题 When let users sign in using Facebook, I create a new devise user after first authentication, the question is what is the better practice to do regarding the password of newly created user ? 1. Fill it with a random token? Then, how would the user know the newly created password ? a. Shall I send him an email? b. Write it as a flash message after his first Facebook authentication ? I know that user might not need to have a password as he can always sign in with Facebook, but, he might need to

How can I avoid Devise from requires authentication from within an engine?

﹥>﹥吖頭↗ 提交于 2020-01-05 23:29:36
问题 I'm using Devise for athentication in my main application and I have built an API (for a PABX) using "http_basic_authenticate_with" and it's working well when I add before_action :authenticate_user!, except: [:method_name] to my controller. I'm doing that because except: [:method_name] will not require a logged user session on Devise and I just want to use basic authenticate for those API controllers. config/routes.rb (main application) scope module: 'api' do scope module: 'pabx' do scope '

How can I avoid Devise from requires authentication from within an engine?

蓝咒 提交于 2020-01-05 23:27:53
问题 I'm using Devise for athentication in my main application and I have built an API (for a PABX) using "http_basic_authenticate_with" and it's working well when I add before_action :authenticate_user!, except: [:method_name] to my controller. I'm doing that because except: [:method_name] will not require a logged user session on Devise and I just want to use basic authenticate for those API controllers. config/routes.rb (main application) scope module: 'api' do scope module: 'pabx' do scope '

Devise: custom fields not saved after signing up

随声附和 提交于 2020-01-05 23:00:29
问题 Environment: Rails 4, Devise 3.2.2 Given I added two fields (name, profession) to my devise model. When I sign up Then I see in the database the new columns not affected. Below are my controller and model classes #custom controller class UsersController < Devise::RegistrationsController before_action :configure_permitted_parameters #devise's controller extensions protected def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) do |u| u.permit(:name, :email, :profession,

Devise: custom fields not saved after signing up

强颜欢笑 提交于 2020-01-05 23:00:29
问题 Environment: Rails 4, Devise 3.2.2 Given I added two fields (name, profession) to my devise model. When I sign up Then I see in the database the new columns not affected. Below are my controller and model classes #custom controller class UsersController < Devise::RegistrationsController before_action :configure_permitted_parameters #devise's controller extensions protected def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) do |u| u.permit(:name, :email, :profession,

REST API Testing - Postman behaving as different client after each request

删除回忆录丶 提交于 2020-01-05 17:37:01
问题 I am currently using Postman to test my REST API. I've built it using Ruby-On-Rails , and using devise_token_auth to manage users sessions. After a successful log in, my API is rendering a client , an access-token , a token-type (BEARER) and an Uid . These elements are needed for every request that requires the user to be logged in and have to be sent on the header. Let's say I am creating an article using a POST. The first POST succeeds and creates the article but when I try to create

Login to a RESTful Rails app with HTTParty

萝らか妹 提交于 2020-01-05 12:09:17
问题 I have a web app with a clean RESTful JSON API, based on Rails 3.2 , Ruby 1.9 and Devise 2 . I would like to write a small script based on HTTParty web client in order to perform some actions frequently (with a crontab). But how can we sign in and keep the session open (with the session id passed by HTTP HEADER, and maybe stored in a cookie). I really have no experience about this aspect. 回答1: According to this mailing list comment as of January, may not be possible: https://groups.google.com

Rails: Switch User Gem and issues with switching back to original user

两盒软妹~` 提交于 2020-01-05 10:09:08
问题 In my app I am using the switch_user (https://github.com/flyerhzm/switch_user) gem to allow admins to login as another user. The gem has the ability to log back in as an admin, but I am having a hard time conceptualizing how to do it. Here is my config: SwitchUser.setup do |config| # provider may be :devise, :authlogic, :clearance, :restful_authentication, :sorcery, or :session config.provider = :devise # available_users is a hash, # key is the model name of user (:user, :admin, or any name

Rails 4 - devise_for not using custom controllers

痴心易碎 提交于 2020-01-05 08:57:13
问题 I use Devise in my Rails app, and I would like to customise some of it's behaviour. I have read the documentation for devise_for . But I can't get it to use my custom controllers. My routs looks like this: devise_for :users, controllers: { sessions: "users/sessions", registrations: "users/registrations" } In my Users::RegistrationsController < Devise::RegistrationsController I have tried the following: # POST /resource def create puts "I'm here" # never happens! super end Any ideas on what I