devise

How do you access Devise controllers?

倖福魔咒の 提交于 2020-01-19 04:32:08
问题 Are controllers in devise automatically generated? How do you access them? I know for views you do rails generate devise_views . 回答1: Devise uses internal controllers, which you can access and subclass in your own code. They are under the Devise module. For example, to extend the RegistrationsController : class MembershipsController < Devise::RegistrationsController # ... end Then all you have to do is configure Devise's routes to use your controller instead: devise_for :members, :controllers

Rails Devise Build nested model in controller

╄→гoц情女王★ 提交于 2020-01-17 08:47:48
问题 I'm using Devise and am trying to build nested models in my RegistrationsController . Though this is not working. I can build nested models via resource.build_nested_model in the view, but not in the controller itself. This is my registrationscontrollers' new-action def new super resource.build_user_info resource.user_info.languageskills.build if params[:is_driver].to_i == 1 resource.build_driver end Rails.logger.debug(resource.build_user_info.inspect) end This is the output it generates:

How do I log in a user with Devise for Rails controller/integration unit tests?

China☆狼群 提交于 2020-01-17 06:57:06
问题 All the other answers are wrong or out of date. I've tried several things. This is what I have: require 'test_helper' class DealsControllerTest < ActionDispatch::IntegrationTest include Devise::Test::IntegrationHelpers setup do @deal = deals(:one) @user = users(:one) # https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-(and-RSpec) #@request.env["devise.mapping"] = Devise.mappings[:one] #sign_in @user #log_in_as @user ApplicationController.allow_forgery

LoadError in Devise::RegistrationsController#create (cannot load such file — bcrypt_ext). Why do I get this error?

点点圈 提交于 2020-01-17 06:16:06
问题 I'm using ruby 2.2.4. I get this error when I tried to sign up after installing the Devise gem. I never experienced this error when I used to use ruby 2.1.5. Is the ruby version the cause of the error here? UPDATE: this is what my gemfile looks like and I'm using Windows 7 Professional 64-bit source 'https://rubygems.org' gem 'rails', '4.2.5.1' gem 'sqlite3' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.1.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder',

Rails 4 link_to url causes browser to GET when it should DELETE

你离开我真会死。 提交于 2020-01-17 04:14:06
问题 Searching around, I see that variations on this question used to be asked on StackOverflow fairly often, but nothing in recent years. That makes me wonder if perhaps I have something that is out of date, perhaps a Javascript library. We just started working on a new Rails 4 site, using Ruby 2, however we accepted the frontend code from our designer, and we used it mostly untouched. That includes: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> We have

Rails Trying to create a profile after the user has been created

試著忘記壹切 提交于 2020-01-16 20:10:26
问题 I'm trying to figure out how to create a new profile for the user that has just been created, I'm using devise on the User model, and the User model has a one to one relationship with the UserProfile model. Here's what my User Model looks like: class User < ActiveRecord::Base has_and_belongs_to_many :roles belongs_to :batch has_one :user_profile after_create :create_user_profile def create_user_profile self.user_profile.new(:name => 'username') end # Include default devise modules. Others

Make a fields_for block conditional

≯℡__Kan透↙ 提交于 2020-01-16 20:01:11
问题 I have a User Model and an Instructor Model. There is a one-to-one relationship between user and instructor. And some users will be instructors and some will not. As such I have a registration form that uses a fields_for method to write to both. How can I write to the instructor table only on the condition that they say they are an instructor, such as through a checkbox. And when they do write I want to maintain my validations of the table along with the rest of the form Ideally this would

Make a fields_for block conditional

烈酒焚心 提交于 2020-01-16 20:01:10
问题 I have a User Model and an Instructor Model. There is a one-to-one relationship between user and instructor. And some users will be instructors and some will not. As such I have a registration form that uses a fields_for method to write to both. How can I write to the instructor table only on the condition that they say they are an instructor, such as through a checkbox. And when they do write I want to maintain my validations of the table along with the rest of the form Ideally this would

Error adding value names to devise

試著忘記壹切 提交于 2020-01-16 03:29:18
问题 Im getting an error trying to add the value name to devise, I think all did all things to make it work, but it doesnt work. NoMethodError in Devise/registrations#new undefined method `name' for #<User:0x00000002e4e038> Here is my user model: class User < ActiveRecord::Base include Gravtastic gravtastic :size => 165, :filetype => :png, :rating => 'R' # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and

How to do browser-based new user approval by Admin in Rails 3.2 using Devise

做~自己de王妃 提交于 2020-01-16 01:15:52
问题 I created a simple directory using Rails 3.2 and devise where new users need approval before they can use the site. I followed the instructions in "How To: Require admin to activate account before sign_in" and admin users can now see lists of different index pages of approved versus non-approved users. So far so good. My problem is the user approval process. Currently I approve users in the Rails console. I'd like for admin users to be able to approve users through their browser. I'm at a