- Only if many roles are used:
- Generates habtm table, creates role.rb with the habtm declaration. Adds declaration in user.rb (scans the code for "class User < ActiveRecord::Base", and puts the new code right after it.
- Creates an admin user in users.yml, with a role named admin in roles.yml, including a fixture to demonstrate how to relate roles to users in roles_users.yml
- Modify the user.rb (or corresponding user model) file, add the instance method has_role?
- Generates RoleRequirementSystem against for the corresponding user model.
- Generates a migration to make the necessary database changes
- Scans ApplicationController, inserts the lines "include AuthenticatedSystem", and "include RoleRequirementSystem", if not already included.
- Scans test_helper.rb and adds "includes RoleRequirementTestHelpers", if not already included.
|
The line 'script/generate authenticated user sessions' doen't work for me (I'm on Windows XP). So I tried 'script/generate authenticated user sessions'. It gave the following error: Couldn't find 'authenticated' generator. So what's wrong here?
I have Rails 2.2.2 and this comand doesn't work for me. May by you should write 'ruby script/generate model User (fields if needed)'
@s.cambour... Make sure you download the restful_authentication plugin before running the 'ruby script/generate authenticated user sessions' command. If you have downloaded it, make sure the restful authentication folder in the vendor/plugins directory is called 'restful_authentication' instead of 'restful-authentication'.
If your using 2.3 you'll need to update line 52 in role_generator_helpers.rb to point to application_controller.rb instead of application.rb for the generator to work.
@funkjedi: The source seems to have been updated to do this automatically now.
When I run "./script/generate authenticated user sessions \ —include-activation \ —stateful \ —rspec \ —skip-migration \ —skip-routes \ —old-passwords ", all I get is Couldn't find 'authenticated' generator