[筆記] 實作 JDStore 前置

(注意:這篇沒有安裝bootstrap/alert功能)

git init

.gitigonre
...()
+config/database.yml
gemfile
-gem 'sqlite3'
+gem 'awesome_rails_console' #美化console 顯示數據

+gem 'font-awesome-rails' #awesome icon

+gem 'awesome_print' #美化ruby

+gem 'pry' #debug

+gem 'annotate' #加入schema

+gem 'bootstrap-sass'
+gem 'devise' #login/out

+gem 'simple_form'

group :development, :test do
  gem 'byebug', platform: :mri
+ gem 'sqlite3'

+group :production do
+  gem 'pg'
+end

bundle install

app/assets/stylesheets/application.css->app/assets/stylesheets/application.scss

app/assets/stylesheets/application.scss
+*= require font-awesome
+@import "bootstrap-sprockets";
+@import "bootstrap";
+@import "font-awesome";
app/assets/javascripts/application.js
+//= require bootstrap/
//= require_tree .

安裝simple_form
rails generate simple_form:install --bootstrap
安裝devise
rails g devise:install
rails g devise user
rake db:migrate



安裝bootstrap html
https://fullstack.xinshengdaxue.com/posts/56

mkdir app/views/common
touch app/views/common/_navbar.html.erb 內容可參考下面
https://www.w3schools.com/bootstrap/bootstrap_navbar.asp
touch app/views/common/_footer.html.erb
https://www.w3schools.com/tags/tag_footer.asp

app/views/layouts/application.html.erb
<!DOCTYPE html>
<html>
    <head>
        <title>Rails101</title>
        <%= csrf_meta_tags %>

        <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
        <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
    </head>

    <body>

        <div class="container-fluid">
    +       <%= render "common/navbar" %>
            <%= yield %>
        </div>

    +       <%= render "common/footer" %>

    </body>
</html>

產生welcome 頁面 controller
rails g controller welcome
touch app/views/welcome/index.html.erb

首頁指向welcome/index.html

config/routes.rb
Rails.application.routes.draw do
  root 'welcome#index'
end

git add .
git commit -m "start settings"

github 開一個repo 「jdstore2」
git remote add origin git@github.com:"userID"/jdstore2.git
git push -u origin master

git checkout -b start
下次要重做切回start這個分支就好 ,後面checkout story1-> story1-v1

comments powered by Disqus