devise

Confused about strong parameters with Devise

。_饼干妹妹 提交于 2019-12-24 23:19:02
问题 I have the following Devise registration form (with irrelevant markup omitted): <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { id: "payment-form" }) do |f| %> <%= f.fields_for resource.paid_account do |pa| %> <%= pa.collection_select :account_plan_id, @account_plans, :id, :name_with_price %> <% end %> <% end %> This form spits out the following HTML: <select id="user_paid_account_account_plan_id" name="user[paid_account][account_plan_id]"> <option

Overriding Devise SessionsController#Create and create view - and authentication fails

不羁的心 提交于 2019-12-24 22:19:45
问题 I have a user login page which was adapted from the devise login view and I am overriding the controller because I need to perform several tasks on login, but I can't get past step 1 (warden authentication. Inside Users::SessionController < Devise::SessionsController, I simply have def create super [...other post authentication code] end Debugging into super.create I can see that it calls self.resource = warden.authenticate!(auth_options) but it never retu8rns from the call to super. Somehow

Displaying posts by specific user?

爱⌒轻易说出口 提交于 2019-12-24 22:18:57
问题 Here I have some code: def show @post = Post.find() end end the user model has has_many :posts and the post model has belongs_to :user. Now how can I make the show action only display posts by the user logged in. User logged in is "current_user"? 回答1: You could do this: def show @post = Post.where(user_id: current_user.id) end But there is glitch with the variable, you should rename @post to @posts since this will be an array of several Posts (if so, don't forget to change the variable in

How to add a new flash message to devise.en.yml?

旧街凉风 提交于 2019-12-24 22:18:26
问题 I want to display a new flash msg on logout under a particular condition.. I'm overriding the after_sign_out_path_for method in application_controller.rb . I have added a new msg in devise.en.yml too. How do I flash the new msg on logout when its redirected to sign in page??? application_controller.rb: def after_sign_out_path_for(resource_or_scope) if is_already_logged_in? flash.keep[:notice] = t("devise.failure.concurrent")// IS NOT WORKING new_user_session_path else new_user_session_path

Sendgrid v3 not working for me with rails my_mailer.rb

余生颓废 提交于 2019-12-24 21:13:37
问题 I want to send a transactional mail via Sendgrid when a user registers (I use devise for authentication). I had this working fine in my_mailer.rb using SMTP as follows: def confirmation_instructions(record, token, opts={}) # SMTP header for Sendgrid - v2 # headers["X-SMTPAPI"]= { # "sub": { # "-CONFIRM_TOKEN-": [ # token # ] # }, # "filters": { # "templates": { # "settings": { # "enable": 1, # "template_id": "1111111-1111-1111-1111-111111111111" # } # } # } # }.to_json However, prompted by

Rails 5, devise nested attributes, unpermitted parameters

梦想与她 提交于 2019-12-24 20:52:38
问题 I'm using Devise in my Ruby on Rails application. When users signs up or updates their account I also want to create / update their AddressInformation . class User < ApplicationRecord belongs_to :address_information accepts_nested_attributes_for :address_information, allow_destroy: true [...] My _form.html.haml looks like this: = form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| = devise_error_messages! .form-group = f.label :name = f.text_field :name = f

how to redirect devise_for controller to other than default devise

核能气质少年 提交于 2019-12-24 19:05:15
问题 I have devise_for :user, path: 'v1/user', class_name: "V1::User",controllers: {sessions: 'v1/sessions' I like to have it redirect all not just sessions including :omniauth_callbacks to v1/sessions or something like this devise_for :user, path: 'v1/user', class_name: "V1::User",controllers: {sessions: 'v1/sessions'}, controllers: {omniauth_callbacks: 'v1/sessions'} it will errors warning: key :controllers is duplicated and overwritten on line 16 回答1: As stated in my comment, you can just add

Rails devise with omniauth-google-oauth2 image size does not work

不打扰是莪最后的温柔 提交于 2019-12-24 17:24:37
问题 I am building Rails app using devise with omniauth-google-oauth2 . Everthing work well but after i authenticate successfully with google, image hash that i get is: https://lh4.googleusercontent.com/-zE4TdSazXvI/AAAAAAAAAAI/AAAAAAAAACA/jWRW9BtDAlU/s128-c/photo.jpg?sz=50 So, this make my image look so small, it is only 50px. Although in Devise config i use: config.omniauth :google_oauth2, "feaeas", "fefaascea", {:image_aspect_ratio => "square",:image_size => 128} How i can i get the large size

Rails: Resource and Forms

柔情痞子 提交于 2019-12-24 13:47:51
问题 Preface: I'm not sure what resources are. I need this form (which is working from the user/sign_up route) to work on my 'offline page'--so users can still register when my app is down. My application_controller calls a :filter_before, :except => [:offline] and my registrations_controller has a :skip_filter_before action. (Is it called an action?) <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> <%= devise_error_messages! %> <p><%= f.label :email

Rails devise doesn't save extra input fields to database

可紊 提交于 2019-12-24 13:12:22
问题 I'm having problem with inserting extra user fields values to database with Devise gem. What i'm missing? I'm using ruby 2.1.5p273 Rails 4.1.8 This is my user.rb model class User < ActiveRecord::Base belongs_to :country # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable, :authentication_keys => [:login] attr