how to build a blog with rails5 and bootstrap4

1.chapter1
2.chapter2
3.chapter3
4.chapter4
5.chapter5
6.chapter6
7.chapter7
8.chapter8
9.chapter9
10.chapter10
11.chapter11
12.chapter12
13.chapter13
14.chapter14
15.chapter15

1.chapter1
添加bootstrap的gem,链接

#gemfile
gem 'bootstrap', '~> 4.0.0.alpha6'

#application.scss
@import "bootstrap";

#application.js
//= require jquery
//= require bootstrap-sprocket

添加friendly_id这个gem

#gemfile
gem 'friendly_id', '~> 5.1.0' # Note: You MUST use 5.0.0 or greater for Rails 4.0+

#终端
rails generate friendly_id
rails generate scaffold post title:string body:text description:text slug:string:uniq

#post.rb
class Post < ApplicationRecord
  extend FriendlyId
  friendly_id :title, use: :slugged

  def should_generate_new_friendly_id?
    title_changed?
  end
end

#post_controller.rb
#更改方法
User.friendly.find(params[:id])

你可能感兴趣的:(how to build a blog with rails5 and bootstrap4)