Created
December 30, 2014 03:16
-
-
Save rocLv/2beaceccd5409262a2f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
pluralize(1,"error")
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
Rails automatically wraps * the fields with errors * in divs with the CSS class * field_with_errors *. These labels then allow us to style the error messages with the SCSS shown in Listing 7.20, which makes use of Sass’s @extend function to include the functionality of the Bootstrap class has-error.
Other errors methods: