by Michael Hartl
-
-
Save dekom/2129509 to your computer and use it in GitHub Desktop.
yield(:title)
and provide(:title, 'Home')
stylesheet_link_tag 'application', :media => 'all'
,
javascript_include_tag 'application
,
csrf_meta_tags
Also, yield
in application layout? How does it work?
In rspec: let(:base_title) { "Ruby on Rails Tutorial Sample App"}
Rails 3.1+ offers 3 canonical directories for static assets:
- app/assets: assets specific to the present application
- lib/assets: assets for libraries written by your dev team
- vendor/assets: assets from third-party vendors
Each sub-asset directory separating javascript and stylesheets have a manifest file, telling what files to load, using Sprocket syntax.
Preprocessor engines are run depending on the file extensions in the assets pipeline. The default engines for Rails 3.1+ are Sass, CoffeeScript, and ERB. Engines can be chained by adding engine extensions to the files (right to left evaluation).
Notable rspec function used:
before
subject
and shortenedit
make model's attributes accessible with attr_accessible
. Always do this to prevent mass assignment exploits (which happened to Github).
annotate model's attributes with the annotate
gem. Make sure the version is at least 2.4.1.beta
for it to work with newest release of Rake.
Read about Rails's validation methods
Read about RSpec's syntax and methods, especially the new, less verbose calls.
RSpec's let
method:
It "takes a symbol as argument and a block, and creates a local variable with same name as the symbol and its value is the return value of the block.
The magical has_secure_password
method. Source code here
This magical method requires the model (and table) to have password_digest
as one of the columns.