Tag: devise

Ruby on Rails tutorial part two

I keep getting stock [sic] in a RoR tutorial. Part 1 is here. After doing that, I ran the command: rails generate devise User Not sure if that is the correct code to type as the tutorial is not clear. I’m not sure what the command does, and which files are connected to what etc. […]

Error with Rake DB:Migrate undefined method `confirm_within=' for Devise:Module

I’m getting this error when I try run DB:Rake : ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment Resolved collector.newrelic.com to rake aborted! undefined method `confirm_within=’ for Devise:Module /Users/jasonvdm/development/rails/config/initializers/devise.rb:66:in `block in <top (required)>’ /Users/jasonvdm/.rvm/gems/ruby-1.9.3-p194@wheelz/gems/devise-2.1.2/lib/devise.rb:247:in `setup’ /Users/jasonvdm/development/rails/config/initializers/devise.rb:3:in `<top (required)>’ /Users/jasonvdm/.rvm/gems/ruby-1.9.3-p194@wheelz/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load’ /Users/jasonvdm/.rvm/gems/ruby-1.9.3-p194@wheelz/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `block in load’ /Users/jasonvdm/.rvm/gems/ruby-1.9.3-p194@wheelz/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency’ /Users/jasonvdm/.rvm/gems/ruby-1.9.3-p194@wheelz/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in’ /Users/jasonvdm/.rvm/gems/ruby-1.9.3-p194@wheelz/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in […]

Redirect root_path in rails for already signed_in user without using Devise

In my application i have root_path root ‘home#mainPage’ and though a user is signed in , he can accesss http://localhost:3000/ which i dont want. So i am following https://stackoverflow.com/a/8739874/3786657 answer to add this feature and i am getting undefined method user_signed_in? for AuthenticatedUser:Class. I am using Rails 4.2.0 My routes: constraints(AuthenticatedUser) do root :to => […]

Testing models with RSpec using devise

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’ […]

Devise Signout Routing Error

I’m using Devise 1.5.1 in a Rails 3.0.3 app. It works well, with one exception: The signout link gives me this error: Routing Error uninitialized constant UsersController The link that leads to this is: <%= link_to(‘Logout’, destroy_user_session_path, :method => :delete) %> I haven’t created an app/controllers/user_controller.rb file, but my understanding that this wasn’t necessary when […]

Adding Role dynamically through Form USing Rolify along with Devise and Cancan

I just followed the tutorial “https://github.com/EppO/rolify/wiki/Tutorial” its very nice and working fine. But my question can’t we add Role through form with out using Rails console. <div class=”field”><%= user_form.label :email %><br /> <%= user_form.email_field :email %></div> <div class=”field”><%= user_form.label :password %><br /> <%= user_form.password_field :password %></div> <div class=”field”><%= user_form.label :password_confirmation %><br /> <%= user_form.password_field :password_confirmation […]

RSpec: Authenticating before test with devise_auth_token

I am using devise_auth_token to authenticate users for an API. I would like to authenticate users before each test is run, but keep getting a 401 error. When I use postman to the endpoint with the correct headers, it works, but fails to work during tests. before(:each) do @user = FactoryGirl.create(:user) end def get_auth headers […]

How can I add additional columns to a Users table with rails and devise gem?

I am making an app in rails so that when a User adds their medications, it will add the medication in a new column in the Users table. I am using the devise gem with my User model, and I haven’t made any additional changes to the User table other than creating it when running […]

skip_before_filter for the “login” action of devise

I can do this to skip calling “authenticate_user” in a certain controller where I need to: class ApplicationController before_filter :authenticate_user! end class MyController < ApplicationController skip_before_filter :authenticate_user! end I want to call skip_before_filter for “login” action of devise gem and I don’t want to have to override anything else. How can I do that?

Instantiating Devise user models manually using contents of params hash

I’m losing my mind trying to figure this out: There’s a registration module which side-steps the main devise registrations controller, and I have to manually instantiate the Devise-generated user model using User.new(…). I’m using a form_tag to submit all of the necessary parameters necessary for User.new(). Here’s a truncated version of my code: def registration_three […]

Ruby is the best programming language in the world - Ruby on Rails.