A set of custom rails generators for common stub code
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
mendable_auth
mendable_model
mendable_scaffold
.gitignore
README.rdoc

README.rdoc

Rails Generators

My Rails generators to quickly create working stub code for things I repeat often.

mendable_scaffold

Based on scaffold generator from Rails 2.3.3, usage is exactly the same as the standard rails scaffold.

  • Does not include scaffold.css or layout template (I always delete these anyway)

  • Does not include controller specific helpers

  • Adds Destroy link to show page

  • Index page links first column value to the show action

  • Adds a H1 tag to the view page using the first attribute as the value

  • Includes create/edit/destroy icons, to start delivering a polished-app feel immediately

  • Gives the index view table a CSS id for easy styling, and each row a cycle'd class name

  • Uses Shoulda for functional testing

  • CAN BE NESTED, using “–owner=Model” to create nested controller and views!

Usage

$ ./script/generate mendable_scaffold company company_name:string
$ ./script/generage mendable_scaffold employee employee_name:string --owner=Company

mendable_model

Based on shoulda_model from github.com/technicalpickles/shoulda_generator/

  • Same as rails model generator, but with factories and shoulda instead of test_unit

mendable_auth

This was a ground-up rewrite of the restful_authentication generator, the primary purpose was to include missing functionality (such as forgot password actions) and provide a far superior test suite using Shoulda and Factory Girl. mendable_auth should be used at the start of a project where you will need user authentication. It provides a great base on which to build your application.

Features

  • User model with username, email address and password

  • Email model with Signup and Forgot Password emails

  • RESTful Session Controller with Login and Logout actions

  • RESTful User controller including signup and edit account functionality

  • RESTful Forgot Password controller allowing users to reset their password

  • Simple admin system, with is_admin field on users table (Optional)

  • Secure encrypted passwords using BCrypt

  • Full test suite using Shoulda and Factory Girl

  • Test Ratio of 1:1.8 (over 150+ tests)

  • 100% Test coverage (rcov verified)

Usage

$ ./script/generate mendable_auth [--with-simple-admin]
$ sudo rake gems:install
$ rake db:migrate
$ rake test

You can also add this to your application layout to get some quick links working:

<% if logged_in? then %>
  <li><%= link_to 'Edit Account', edit_user_path(current_user) %></li>
  <li><%= link_to 'Logout', logout_url %></li>
<% else %>
  <li><%= link_to 'Login', login_url %></li>
  <li><%= link_to 'Signup', signup_url %></li>
<% end %>

Design decisions

  • Users should log in with their EMAIL address (not username). On the basis that user's should be able to remember their own email address, but usernames for each site they visit is not so likely.

  • Should NOT require user to validate their account by sending them an activation email. This is just plain bad usability, forcing user's to navigate away from your website or application, breaking their concentration, and reducing signup conversion rates.

  • The Model and Controller names are standardized.

mendable_contact_form

Provides a simple contact form allowing users to send an email to the site administrator.

  • Assumes you have used mendable_auth, and you have a current_user function and an Email model

Patches

If you branch and enhance this product in anyway, please do contact me to let me know, either on GitHub (www.github.com/mendable) or through my website (www.mendable.com).

Licence

Copyright © 2009 Jason Lambert (www.mendable.com).

Code released under the MIT license.