devise

Rails: Warden/Devise - How to capture the url before login/failed access

Hi: I am trying to figure out how to redirect a user to the page they logged in from (or failed to login) using Warden/Devise. I figure there is a session variable somewhere that is either available or could be made available. E.g. Scenario 1: Non-authorized user goes to protected page X; Redirected to login page; User logs in; User re...

Password encryption problem in Rails Devise gem

I am now currently changed to use the Gem Devise for user authentication. But I don't know how to match the encryption! I knew that we could write a new encryptor and assign it in initializers, but the point is the encryptor accepts 4 arguments only (password, stretches, salt, pepper). But in my case, I do included the user's email and ...

Cannot expire cached fragment by default methods in Ruby on Rails + Devise

I'm using Devise as authenticating solution in Rails and I have a cached fragment :recent_users. I want this fragment to expire when a new user is registered, changed or removed, so I put in my(manually created) users_controller.rb class UsersController < ApplicationController cache_sweeper :user_sweeper, :only => [:create, :updat...

Devise ignoring custom strategy

This is just plain weird. I've got Rails 3 RC running with Devise installed. I've defined a custom strategy to try and use Kerberos for authentication. module Devise module Strategies class Kerb < Devise::Strategies::Base def valid? params[:username] || params[:password] end def authenticate! ...

Ruby on rails, devise, how to set up a user profile

I'm new to rails, and even more new to devise. I have set up a user controller and I've managed to create a view showing the e-mail address of the current user. Now I want a user profile page, where the user can add personal information etc, and keep track of published posts etc. Basic community functions. How should I design this? Sho...

How do I use nested attributes with the devise model

I have the same issue as http://stackoverflow.com/questions/3027555/creating-an-additional-related-model-with-devise (which has no answer). I have overridden the devise view for creating a new user and added a company name, I have changed the model to use accepts_nested_attributes_for There are no errors, but it is not adding the neste...

devise facebook and tweeter ,github authentication sending wrong url

I am doing this in config/initializer/devise.rb using rails3 rc and ruby 1.9.2rc config.warden do |manager| manager.oauth(:twitter) do |twitter| twitter.consumer_secret = "...key....." twitter.consumer_key = ".....app_key......" twitter.options :site => 'http://twitter.com' end # manager.default_strategies(:scope =>...

Override devise registrations controller

I have added a field to the sign-up form that is based on a different model, see http://stackoverflow.com/questions/3544265/how-do-i-use-nested-attributes-with-the-devise-model for the gory details. This part is working fine. The problem now is when I save, it is failing in the create action of the registrations controller that is suppl...

Rails 3: Devise: No route matches "/"

I'm running into some issues when trying to add Devise to my Rails 3 app. I started by creating a new Rails 3 (rc2) app with a "Home" controller and "index" action and verified that "/" would render "#home/index". Next I set devise 1.1.1 in my Gemfile, installed Devise, created a User model, and migrated the database. Now "/" returns No ...

Rails 3 reset session using devise

Hello, I am developing a Rails3 application and Devise for authentication. In the course of the workflow, I am storing information in the session, like patient_id. But, when the user log's out, I need to clear the session. I could've done it if I has control of user login and logout. But, now devise handles it. How could I do it? ...

How to test devise models, controllers and views using RSpec?

Hi, I am used to generating my rspec controllers & models using rspec_X syntax, e.g. script/generate rspec_model Person script/generate rspec_controller Person However if I want to use devise to create a Person model the syntax is: script/generate devise Person which works OK, but does not create any of the rspec test files / dirs...

devise+cancan not blocking access to index problem wherer @proj = Proj.all

Hello, I have an app that uses Devise and CanCan. in the config>initializers>Abiliity.rb class Ability include CanCan::Ability def initialize(user) if user.is? :superadmin can :manage, :all elsif user.is? :user can :read, Project do |project| project && project.users.include?(user) end ...

Rails 3 using Devise: How to allow someone to log in using their Facebook account?

I have a Rails 3 application using Devise for authentication. Now I need to allow someone to log in using their Facebook account. I think this is called Facebook Connect, but I've also heard the term Facebook Graph API, so I'm not sure which one I'm asking for. What do I need to do in order to integrate Facebook Connect with Devise? ...

How do I add a strategy to Devise

I'm trying to add a really simple strategy to devise, and it doesn't seem to be working. Here is the code that I am trying to use #config/initializers/devise.rb Devise.setup do |config| config.orm = :mongo_mapper config.warden do |manager| manager.strategies.add(:auto_login_strategy) do def valid? params[:auto_l...

Ruby on Rails Devise user

I am new to ruby on rails. I am originally a PHP/mysql programmer. I can not seem to understand how you connect any posts to the user and display them (e.g. a post is successfully created with the user ID and then the users ID is queried to get his or her name.) I am using devise for authentication. def create poll = current_user.p...

How to redirect a user after registration when using Devise?

Hi, I am using Rails 2.3 and Devise to handle user registration / authentication. I need to redirect a user to an external 3rd party website immediately after a user signs up for an account. Been looking in the code & online but cannot see how to do this. How can I alter the devise flow to redirect the user? Thanks! ...

How do I customize the user registration route with the devise gem for Rails?

I use the Devise gem with Rails and would like to alter the action that occurs during user registration. My faulty customization looks like this: devise_for :users, :controllers => { :registrations => "users/registrations" } do post "/", :to => "users/registrations#create_from_admin" end Resulting in this: [bbrasky@admins-Mac...

Redirect to specific URL after logging in

Is there a way in Devise 1.0, the library for Rails 2.3, to redirect to a specific URL and not root_url after logging in? EDIT: forgot to mention it's Devise 1.0 ...

Creating Join Tables for has_many & belongs_to Associations

Hello, Rails 3 newbie here... I'm working to create a devise auth system that like (yammer) has instances where users belong. I have two tables Users (email, password...) belongs_to :instance Instance (domain name, active....) has_many :users I added the belongs_to and has_many to the models but the schema hasn't been updated to a...

Rails 3, CanCan to limit all query results throughout the app based on User's InstanceID

Hello, I have two tables Users (name, email, password, instance_id, etc...) example: james bond, [email protected], 1 Instance (id, domain) example: 1, abc.com Through out the application I want to make sure James Bond only sees data that is assigned to his instance = 1 So if I have a books table with (name, desc, instance_id), he only ...