Skip to content

Instantly share code, notes, and snippets.

@adriand adriand/gist:10890369 forked from SeanRoberts/gist:9347648
Last active Aug 29, 2015

What would you like to do?
- Use latest stack (Ruby 2.1.x, Rails 4.x, Postgresql)
- Prefer the new hash syntax, but use the old one when necessary (ie. when you need to use strings as keys)
- Code in ActiveRecord models should pertain directly to storing or retrieving data
- Use Draper to decorate model instances and test your decorators with RSpec (app/decorators is the place for this)
- Put business logic into service classes and test them with RSpec (app/services is a fine place for this, you can get more specific if your services folder gets fat)
- I like to name my service classes after what they do, or give them cute names occasionally (AddsProductstoCart or CartStuffer)
- Don’t hesitate to namespace related models or services into modules.
- Use Resque and Redis for background job handling.
- Testing should be the rule, not the exception
- Use rspec and cucumber for user acceptance testing (when needed)
- Use Profound grid for your layout, Jamie can furnish you with a starting point
- Write your skeletal layout code before digging into your CSS (aka content-first approach)
- Keep templates small. Use partials and put heavy logic into decorators or helpers.
- Separate concerns by files. Take a look at how Jamie has organized McHattie’s CSS.
- Target elements by classes or nested selectors, save IDs for Javascript
- Prefer CSS solutions to JS ones, if they work in supported browsers
- Write CoffeeScript
- Use the dispatcher pattern to write page-specific Javascript. Don’t put any Javascript in your templates ever.
- Use data tags to ferry information from the server-side to Javascript.
- Write features as CoffeeScript classes and namespace them under APP.features.
- Keep methods under 5ish lines.
- Keep files under 100ish lines.
- Write classes with an interface. “Private” methods should begin with an underscore.
- Variables that refer to a jQuery object should start with a $
- JS should be tested, especially if it is adding essential functionality (testing lib uncertain, perhaps Sinon?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.