Skip to content

Instantly share code, notes, and snippets.

@rocLv
Created December 30, 2014 03:16
Show Gist options
  • Save rocLv/2beaceccd5409262a2f3 to your computer and use it in GitHub Desktop.
Save rocLv/2beaceccd5409262a2f3 to your computer and use it in GitHub Desktop.
link_to
image_tag
link_to image_tag(“rails.png”, alt: “Rails logo”), “#”
<%= debug(params) if Rails.env.development %>
Because we used theimage_tag helper in Listing 5.2, Rails will automatically find any images in theapp/assets/images/ directory using the asset pipeline (Section 5.2).
The directory
app/assets/stylesheets/
is part of the asset pipeline (Section 5.2), and any stylesheets in this directory will automatically be included as part of the application.css file included in the site layout.
When creating a column in a database, it is important to consider whether we will need tofind records by that column.
In Listing 6.31, we could have written the assignment as
self.email = self.email.downcase
(where self refers to the current user), but inside the User model the self keyword is optional on the right-hand side:
self.email = email.downcase
Add bootstrap css to stylesheet:
@import "bootstrap-sprockets";
@import "bootstrap";
@rocLv
Copy link
Author

rocLv commented Dec 30, 2014

Conveniently, a Sessions helper module was generated automatically when generating the Sessions controller (Section 8.1.1). Moreover, such helpers are automatically included in Rails views; by including the module into the base class of all controllers (the Application controller), we arrange to make them available in our controllers as well (Listing 8.11).

 #app/controllers/application_controller.rb
 class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  include SessionsHelper
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment