YARS now available for public use
In a previous post, I mentioned that Jay and I were working on a basic skeleton for a generic Rails app. The idea was to extract the common code that we almost always use in our applications and create a 'standard' project from which we can start new applications without having to worry about basic and repetitive stuff like layouts, user authentication, etc.
Well, the skeleton is now ready, and available for public use from GitHub. YARS (YARS is Another Rails Skeleton) comes pre-initialized with a convenient set of plugins, libraries, controllers & views. It also contains a modified scaffold generator that creates much simpler (non-RESTful!) controllers and views. To use it, you simply clone the repository and
- Edit
config/database.yml - Edit ActionMailer, ExceptionNotifier, and SYSTEM_NAME setups in
config/environment.rb - Run
rake db:migrate - If you want, edit
public/stylesheets/application.css(but not blueprint, so we can upgrade it later if necessary)
And then you're ready to go!
Packages Included
Plugins
- acts_as_taggable_on_steroids
- file_column
- will_paginate
- exception_notification
- action_mailer_tls
- restful_authentication
- role_requirement
- better_nested_set
- ssl_requirement
- BackgroundJob (BJ)
- assert_valid_markup
CSS
Added/changed behaviors
Scaffold Generator
$ ruby script/generate scaffold Model field1:type field2:type
- Generates simple controller with four methods: index, new, edit, delete
- new and edit handle GET requests to display the form, and POST requests to process it
- All actions redirect back to index
- Two simple views: edit, and index
Restful_Authentication
- Modified so that users are only identified by email and password (not by username / login).
- Added method to change_password (
/change_password) - Added method to retrieve forgotten password (
/amnesia). The method allows the user to specify a new password, which is stored but doesn't automatically replace the current password. An email is sent to the user's address with a link to confirm the change. When the link is followed, the newly set password replaced the old one, and the user is redirected again to the login page. - Sends link to confirm password change in the background, using BackgroundJob (BJ). See
jobs/email_changed_pwd.rb - Requires SSL for login and signup
Roles
- Added default roles admin and user
- When a new account is created via Restful_Authentication, it makes it by default be a user
ssl_requirement
- Use by specifying
ssl_requiredin your controller (and specify actions if necessary) - Turned off by default in development mode (see
ApplicationController)
Layout
- Uses blueprint to create basic grid.
- Header has SYSTEM_NAME (defined in
environment.rb), and links to Log In/Out and Sign Up - Footer shows AUTHOR_NAME with link to AUTHOR_URL (defined in
environment.rb)
ActionMailer
- Setup to use action_mailer_tls, so that it sends email via GMail.
- See
UsersController/amnesiaandjobs/email_changed_pwd.rbto get an idea of how to send email in the background.
See the DETAILS file for more information about the setup of each plugin, and let us know if you have any questions. Of course, feel free to fork and extend in your own way!
