devise

Rails 4: CanCanCan abilities with has_many :through association

南楼画角 提交于 2019-12-24 05:03:13
问题 I have a Rails app with the following models: class User < ActiveRecord::Base has_many :administrations has_many :calendars, through: :administrations end class Calendar < ActiveRecord::Base has_many :administrations has_many :users, through: :administrations end class Administration < ActiveRecord::Base belongs_to :user belongs_to :calendar end For a given calendar , a user has a role , which is define in the administration join model. For each calendar, a user can have only one of the

RSpec controller test error: controller does not implement method

扶醉桌前 提交于 2019-12-24 04:26:06
问题 I've written some custom code for Devise registration. Namely once a user hits the "sign up" button, Devise's generic code ensures that the user is saved correctly. But then, I want to go in and make sure that the user gets an associated Stripe customer account. Most of the code below is from Devise, except for a few lines that I added: class Users::RegistrationsController < Devise::RegistrationsController def create build_resource(sign_up_params) resource.save yield resource if block_given?

Rails add new view to devise

…衆ロ難τιáo~ 提交于 2019-12-24 03:55:14
问题 I have generated views with this command after I installed devise rails generate devise:views and I override registration controller by class RegistrationsController < Devise::RegistrationsController def sign_up2 end end And updated routes.rb with devise_for :users, :controllers => { :registrations => "registrations" } I expected to see a new route/view of /users/sign_up2 but I don't see it And here routes for devise new_user_session GET /users/sign_in(.:format) devise/sessions#new user

ActionMailer not delivering confirmation emails in test environment - Rails 4

六月ゝ 毕业季﹏ 提交于 2019-12-24 03:27:11
问题 I'm using Rails (4.2.6), Ruby (2.2.4), Devise (4.1.1), Capybara (2.7.1), Capybara-email (2.5.0), Email_spec (2.1.0), Rspec (3.4.0), and Postgres (0.18.4) After I upgraded the application from Rails 4.1.15 to 4.2.6, several authentification & registration tests fail. Before the upgrade all tests were properly passing. The code works as expected in the development environment (for example, confirmation emails are sent & viewable in the Rails server terminal). The problem of non-delivered emails

PGError: ERROR: column “email” of relation “users” already exists

北战南征 提交于 2019-12-24 03:16:12
问题 I've been developing a website on localhost and it wors fine. This morning, I've tried to push it to heroku using the command "git push heroku master" and then "heroku run rake db:migrate". When I try to do the second one, I have an error: Connecting to database specified by DATABASE_URL Migrating to DeviseCreateUsers (20130427200347) Migrating to CreateAuthentications (20130427210108) Migrating to AddTokenToAuth (20130427233400) Migrating to AddNotificationToAuth (20130427234836) Migrating

Ruby on Rails: Devise - password change on first login

安稳与你 提交于 2019-12-24 02:13:55
问题 I have an app that allows users to enter projects into a database, where they can search for them later. Each user has their own login, which will be given out by a system admin. When the user logs in for the first time, I want the usual homepage to show a "Change your password" view, so that the user has to change their password before using the app. I have set up a pass_change boolean column in the User table, which is false when a new user is created. At the moment, when the user logs in

How to test ActionCable along with Devise using rspec?

北慕城南 提交于 2019-12-24 01:22:44
问题 In my Rails (5.1) application I'm using devise for authentication and ActionCable. My ActionCable connection looks like: module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect puts 'current_user:', current_user.inspect self.current_user = find_verified_user logger.add_tags 'ActionCable', current_user.id end def disconnect # ... end protected def find_verified_user verified_user = env['warden'].user return verified_user if verified_user

Rails + Devise: How to override redirect for the before_filter “authenticate_user!”

旧巷老猫 提交于 2019-12-24 00:55:35
问题 I am on Rails 3 and the latest version of Devise, and I have a before filter in my AdminController to authenticate_user! I need to store a session variable for the request.referrer before it redirects so that I can send it back to the /admin page when they try to go on it. Where would I overwrite authenticate_user! ? What I want to do is this, but I don't know where to define it: def authenticate_user! session[:return_to] = request.request_uri super end 回答1: You don't actually need to do that

Allowing to pass an array in DeviseTokenAuth strong params

北城以北 提交于 2019-12-24 00:54:44
问题 I am having an issue with strong params, passing an array in Devise Token Auth gem LINK # ERROR Unpermitted parameters: options Configure Permitted Params def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) << [:username, options: []] end # also added in User.rb file attr_accessor :options I have tried many options, but its not allowing me to pass a data in array. Is there any solutions ? Thank You! 回答1: Here is the example that will help you to setup the parameters: #

ruby on rails 4 - devise - send_reset_password_instructions - reset password - Reset password token is invalid

泪湿孤枕 提交于 2019-12-24 00:43:32
问题 I am using ruby on rails version '4.2.4' and devise 4.0.0 gem 'rails', '4.2.4' devise (4.0.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0, < 5.1) responders warden (~> 1.2.3) Taking over some code made from someone, they have implemented reset password but didnt quite work. I am trying to solve it. from the console, I tried to use this: > u = User.first > u.send_reset_password_instructions this is console output: [15] pry(main)> u.send_reset_password_instructions Devise::Mailer