I'm creating a Rails app using Devise for user management (Rails 3.0.10, Devise 1.4.2). I've got the basics going - signup, login / logout - but I can't seem to find any facility (or even documentation surrounding) user management.
In other Rails apps I've created, I've had a UsersController with an index method that allows an administrator to list all the users of a system, & to subsequently modify them through edit and update actions on the same controller.
I can't see an obvious way of doing this with Devise. I've used the Rake tasks that come with Devise to generate editable views, which is great, but I can't figure out how to do the equivalent with the Controller.
I fear I'm missing something fundamental here. Could someone please point me in the right direction?
Devise doesn't come with any sort of Admin interface. If you are the only administrator and don't mind a little crudeness - there is always the console and/or scaffolding.
There are also a lot of good gems that make setting up admin interfaces a cinch: Active Admin, Rails Admin and I'm sure there are a bunch more out there.
Related
There are plenty of articles and resources out there about different options for authenticating and accessing a user's information via a Rails 5 API, such as Knock, Doorkeeper, JWT, etc, but I am having trouble finding a solid recommendation on how to handle the actual registration of a new user and related features (i.e. password requests).
I could use Devise, but I wonder if it's overkill. In fact, many articles dealing with JWT, as well as gems like Knock, recommend against it.
Is there a different recommended solution for handling new user registration when building a Rails 5 API only application or is Devise still the best way to go here, even with all the other overhead? Does Rails 5 have something built in?
I`m in the same situation like you I wanted to build a rails 5 api and use JWT but a all the articles omits the register part :S I though like you on use Devise but we only need the register part we wouldn't need the authentication and other modules that are on devise, so the solution would be add register functionality from scratch or if you don't want to code something from scratch then you can use devise but modified to work along with token authentication see this wiki post
I'm new at RoR but I'm loving every bit of it :)
I have a small app that uses devise for authentication and it's working fine.
Now I want to add a ecommerce part nad I decided for spree. I installed spree and during installation it asked me if I wanted to use the default authentication, I said 'no'. Then it asked me for the user model which I stated 'User'.
Now I enter my app, I login it goes to the products page on spree. That's ok, but when I try to access the admin part, I get redirected to the products page.
My doubts are:
- Should I install anyway the spree_auth_devise gem?
- Should this be a problem with the database and the users role? Because on the "spree_users" table I don't have anything, only on the Users table...
How can I associate one of my existing users to an admin user on spree?
Should this be the problem or I'm missing something else?
Did you run this:
rails g spree:custom_user User
http://guides.spreecommerce.com/authentication.html in the Initial Setup block
To check is user is admin:
user = User.find_by_email("master#example.com")
user.spree_roles << Spree::Role.find_or_create_by_name("admin")
## To test that this has worked, use the has_spree_role? method, like this:
user.has_spree_role?("admin")
I have a rails 3.0.9 application that is using Devise for user authentication. It was previously using SQLite, but I changed my application's database to MySQL.
Upon switching to MySQL, the user registration function of Devise stopped working. I'm not getting an error in the rails log. When a new user tries to register, they are simply routed back to the signup page after clicking 'Submit.'
Are there any DB references in the Devise config files that I need to change in order to having Devise play nicely with MySQL?
I should also not that user login / logout is working correctly under MySQL.
I just realized that I had added a before_save :default_values filter on my user model. I originally did this to set default values for certain attributes on the model level. I instead ran a migration setting defaults at the DB level, deleted the before_save call from the model, and everything worked fine.
Silly mistake. Hopefully this helps someone else.
I'm using devise on rails3 and I'd like to implement "su" with it.
To debug my application, it sometimes helps a lot to see exactly what the user who is having the problem is seeing. Therefore I would like to have the possibility (as an admin) to switch to that user without needing to know his password. Just like su on linux systems.
I've seen it done for authlogic (http://blog.steveklabnik.com/2010/03/05/writing-a-su-feature-with-authlogic.html).
The final outcome should be, that when I call /admin/su/5 as a User with the role "admin" I should be logged in as the user with id 5.
Any help or pointers into the right direction are creatly appreciated.
From Mike Barinek
Fast user switching with Devise
This sounds like what you're requesting, and even includes cucumber specs.
I've got a rails 3 app in beta right now that uses Devise for authentication for users, and need some advice. I want to add an admin-user that has some additional abilities, but I will be the only admin user (or admin users can be created via terminal - ie people cannot sign up to be admin users). All regular users have the same abilities. I was just about to use cancan to separate abilities based on user roles. Then it occurred to me that using cancan may just be overkill. does it make sense to just create a different class of user instead? Am I giving anything up by doing this?
I can foresee in the future that if this app is successful, there may be different roles for users (a free versus paid account, etc). Even in that case, does it make sense to NOT have an admin user via devise? Thoughts?
Thanks!!
If you only have two types (users and admins) it seems perfectly fine to have two classes. It might even be easier to implement than a full-fledged role system. But if it is foreseeable that you will get more roles in the future it would be better to lay a solid foundation and use a role system from the start.
If you are the only admin, I would create a field in your user model called Admin and then when you are going to add a function that is only for you, use the admin? check in your code.
For most of my projects, I have been using Devise and then use Option 2 from their Admin Role Wiki which is super easy to implement.