devise

Rails 4 + Devise + Rails API: undefined method 'flash'

一曲冷凌霜 提交于 2021-02-07 07:15:57
问题 I have an existing Rails 4 application which uses Devise and Omniauth . I'm trying to modifying my existing app to develop an API (I mean I will have my web app as it is and also I want an API for mobile app) but I'm having a hard luck. I'm following the steps that are listed in Rails-API under "For already existing apps" section and now I'm getting the below error undefined method `flash' for #<Devise::SessionsController:0x000000098221d0> The error pops at this line <% unless flash.blank? %>

Rails 4 + Devise + Rails API: undefined method 'flash'

瘦欲@ 提交于 2021-02-07 07:14:13
问题 I have an existing Rails 4 application which uses Devise and Omniauth . I'm trying to modifying my existing app to develop an API (I mean I will have my web app as it is and also I want an API for mobile app) but I'm having a hard luck. I'm following the steps that are listed in Rails-API under "For already existing apps" section and now I'm getting the below error undefined method `flash' for #<Devise::SessionsController:0x000000098221d0> The error pops at this line <% unless flash.blank? %>

Rails 4 + Devise + Rails API: undefined method 'flash'

喜你入骨 提交于 2021-02-07 07:12:29
问题 I have an existing Rails 4 application which uses Devise and Omniauth . I'm trying to modifying my existing app to develop an API (I mean I will have my web app as it is and also I want an API for mobile app) but I'm having a hard luck. I'm following the steps that are listed in Rails-API under "For already existing apps" section and now I'm getting the below error undefined method `flash' for #<Devise::SessionsController:0x000000098221d0> The error pops at this line <% unless flash.blank? %>

Nested Resource with Devise - Rails3

独自空忆成欢 提交于 2021-02-06 20:05:42
问题 I'm trying to setup a profiles controller to work with devise registered members. I've created the Profile model & controller and added a one-to-one relationship by adding belongs_to :member to my profile.rb model and has_one :profile in my member.rb model. To create the nested resource I used: devise_for :members, :path => "accounts",:path_names => { :sign_in => "login", :sign_out => "logout", :sign_up => "register" } resources :members do resources :profiles end Calling rake routes outputs

Nested Resource with Devise - Rails3

痴心易碎 提交于 2021-02-06 20:01:11
问题 I'm trying to setup a profiles controller to work with devise registered members. I've created the Profile model & controller and added a one-to-one relationship by adding belongs_to :member to my profile.rb model and has_one :profile in my member.rb model. To create the nested resource I used: devise_for :members, :path => "accounts",:path_names => { :sign_in => "login", :sign_out => "logout", :sign_up => "register" } resources :members do resources :profiles end Calling rake routes outputs

How to edit create registrations_controller action using devise?

老子叫甜甜 提交于 2021-02-04 08:23:22
问题 I'm making a simple app that has the traditional User model, but also a Patients model. I want a user to automatically become a patient on sign up. I've managed to follow instructions here, and can see the file users/registations_controller.rb , but I'm not sure what to add to it. I have pasted the existing devise create code from here def create build_resource(sign_up_params) resource.save yield resource if block_given? if resource.persisted? if resource.active_for_authentication? set_flash

Rails - Pundit - how to check for current_admin_user?

送分小仙女□ 提交于 2021-01-29 06:36:56
问题 I am using Pundit for authorization for my User model. My goal is to extend this to use my AdminUser model, specifically for my admin namespace. By default, Pundit checks for a "user" or "current_user". How can I change this to check for a "admin_user" or "current_admin_user", based on Devise? policies/admin/admin_policy.rb (Closed system, currently looks for User instead of AdminUser) class Admin::AdminPolicy attr_reader :user, :record def initialize(user, record) # Must be logged in raise

sign_in_and_redirect with omniauth-facebook to specific language

倾然丶 夕夏残阳落幕 提交于 2021-01-29 05:43:01
问题 I'm using omniauth-facebook gem with rails 3.2 and devise 2.0. I have a website with 2 languages, english and spanish. http://localhost:3000/en http://localhost:3000/es The gem works fine for english users because in omniauth_callbacks_controller.rb the redirect go to http://localhost:3000/en This is my omniauth_callbacks_controller.rb for facebook: def facebook @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user) if @user.persisted? flash[:notice] = I18n.t "devise

Rails ActionCable Request Origins Subdomain

青春壹個敷衍的年華 提交于 2021-01-29 02:50:40
问题 I'm building a SaaS platform with the apartment gem and am introducing ActionCable for chat functionality. I have most of the chat functionality built, but when transmitting to the channel I get the following: Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket) User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]] An unauthorized connection attempt was

Destroy_with_password always returns false

Deadly 提交于 2021-01-28 20:12:00
问题 Building off of an existing question that walks through how to require a password to delete a user account using the Ruby gem Devise's destroy_with_password . My destroy action looks like this: def destroy @user = User.find(current_user.id) if @user.destroy_with_password(user_params) redirect_to root_url, notice: "User deleted." else redirect_to root_url flash[:notice] = "Couldn't delete" end end def user_params params.require(:user).permit(:first_name, :last_name, :password, :password