devise

Testing against the 'current_user' with Devise in Rails 3

I'm just starting out with Ruby and Rails, trying out Devise with Rails 3. I've got a loop around a list of Posts, each of which has an associated user. I only want to display editing controls for those posts which are associated with the current user. <% @posts.each do |post| %> <%= link_to "show" %> <% if current_user = post.user ...

How do you configure devise to accept either an email OR a username to login?

Out of the box, the devise gem asks for a user's email address and uses that to sign in (authenticate). This railscast, "Customizing Devise", describes clearly how one can authenticate with a username in lieu of an email. How would one configure devise to try to authenticate against two different columns, either username OR email? ...

How to auto-generate passwords in Rails Devise?

I am trying out how Devise works with one of my projects for user authentication. There is a user requirement that their admin should be able to generate a batch of username and user's password from time to time, and then the admin will email the new username and password to his users. Assume the admin has the knowledge of direct SQL on...

Devise and basic auth

Hi, could you tell me plz - is it possible to disable warden/devise for one or more controllers/actions? I need to allow requests with basic auth to one of controllers, but everytime i send similar requests i've seed message, that basi auth is not required for my app. I'm writing oauth2 provider and its a problem to allow client applic...

Adding additional field and validation to Devise view/model in Rails app

I generated the default devise (http://github.com/plataformatec/devise) views with: rails generate devise:views Then I added a username field to the views/devise/registrations/new.html.erb form. Currently, only email and password validation occurs. How do I validate presence and uniqueness of the username field? Do I need to add some...

Rails: Cucumber forgetting CanCan Authorisations

Hi folks, I'm trying to write up some cucumber tests to ensure cancan permissions are set correctly, and I'm having an odd problem: When I log in through the following code, capybara says I've logged in as expected. However, when I then go to a resource which requires the given login, I get CanCan's "not authorized" message. Capybara p...

How to integrate openId with devise in rails 3

I'm new to rails and just got a simple devise setup working. I'm looking to implement something that still uses the core devise feature set but would allow login via openid provider rather than "register w/ email or username" How might I get started with this using the latest devise gem and rails 3? ...

Ruby on rails: Devise, want to add invite code?

Hi, I would like to add an invite_code requirement for users to sign up. Ie. in addition to requiring them to specify an email/password combo, I want an additional field :invite_code. This is a temporary fix so that non-wanted users cannot login during a given alpha period. I'm confused since Devise doesn't add controllers. I'm sort o...

passing values into as_json via options hash?

I'm trying to pass an object (the current user) to be used when rendering the json for a collection. respond_to do |format| format.html # index.html.erb format.xml { render :xml => @items } format.json { render :json => @items.to_a.as_json(:user => current_user) } end However, this seems to have no effect as options[:user] is ...

Roles that are User<>Project Based

Hello... Currently I'm using Devise & CanCan which allows me to create Users with Roles using a (Roles_Users) table. That's nice, but what I want is to Have Projects in my app and for each project for a user to possibly have a role like (Admin, Viewer, etc) IE, roles are not assigned to users but to users based on what projects the...

ruby's oauth2 grant_type

Hi, i started using oauth2 gem by intridea (http://github.com/intridea/oauth2) and don't know how to fix this problem. I have developed both client and server and on request for access_token i see no grant_type parameter. My code from client callback controller class CallbackController < Devise::OauthCallbacksController def accounts ...

Sending delayed email from devise

Is there a simple way of telling Devise to send all email via delayed_job? ...

How do I make an edit users page work on my home page?

Complete rails novice and something just isn't clicking. On my home page /home - I use devise, so I have a check . <% if user_signed_in? %> <%= render "getting_started" %> <% else %> Welcome! <%= link_to "Sign up", new_user_registration_path%> <% end %> At the moment getting_started.html.erb has some instructions and then I'm di...

How to get rid of devise current password requirement when editing a user?

I've followed the instructions here: http://github.com/plataformatec/devise/wiki/How-to-edit-user-form-without-current-password But it seems to ignore that and still validate and require current password. In fact, I can do whatever I want to app/controllers/registrations_controller.rb including putting tonnes of syntax errors in, and ...

Login using Rails Devise and Adobe AMF3

I am trying to login in to my Rails app through an adobe flex application that uses Devise but cannot figure out how to map the AMF request to Devise::SessionsController#New. I tried the following <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="librar...

Multiple Models for one login with Devise?

Is it possible to configure Devise to accept logins for multiple models (either User or Admin) from the same form? ...

Devise authentication gem: How to save the logged in user id?

I'm using the Devise Ruby gem in my Ruby on Rails 3 application. When a logged in user creates one of my models, I want to save their user id as the person who created it. What should I do? ...

rails 3 authentication

i'm currently buidling my own blog using rails 3. and use devise gem for authentication. the problem is , i want only one user out here --- the admin user, and prehibits others from signing up, how can I achive that? ...

Devise : Using Devise Oauth info for facebook interactions.

I have gotten Oauth working with Devise and my users are happily logging in using their Facebook accounts. I would like to allow the users to "like" certain things on my site and post stuff back to their profiles. How do I do that using the information I have (seemingly only an encrypted_password and password_salt)? ...

Best way to handle multitenancy in Rails 3

Hi guys, I'm building multi-tenant application. All data isolation is done by TenantID column in each table. What is the best way to automatically handle multi-tenancy for all tenant models. Example: Contacts.new({.....}) should automatically add :tenant => curret_user.tenant Contacts.where({....}) should also add :tenant => curret_...