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
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac |
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
# app/models/post.rb | |
class Post < ApplicationRecord | |
# friendly url | |
extend FriendlyId | |
friendly_id :title, use: :slugged | |
end |
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
# app/controllers/posts_controller.rb | |
def show | |
@post = Post.friendly.find(params[:id]) | |
end |
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
# config/routes.rb | |
match "/404", to: "errors#not_found", via: :all | |
match "/422", to: "errors#unacceptable", via: :all | |
match "/500", to: "errors#internal_server_error", via: :all |
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
# app/controllers/errors_controller.rb | |
# do not forget to delete public/{404, 422, 500}.html | |
# rm public/{404, 422, 500}.html | |
class ErrorsController < ApplicationController | |
def not_found | |
render status: 404 | |
end |
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
# config/application.rb | |
config.exceptions_app = self.routes |
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
# 301 redirect from old URLs | |
match "/old_path_to_posts/:id", to: redirect("/posts/%{id}s") |
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
# config/meta.yml | |
meta_title: "SEO & Ruby On Rails" | |
meta_description: "The 2018 comprehensive guide on SEO in Rails" | |
meta_image: "logo.png" # Une image dans votre dossier app/assets/images/ | |
twitter_account: "@RevancheSites" |
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
# config/initializers/default_meta.rb | |
# Initialize default meta tags. | |
DEFAULT_META = YAML.load_file(Rails.root.join("config/meta.yml")) |
OlderNewer