1.mkdir 文件夹名称 ----新建一个你需要放专案的文件夹(可省略)
2.rails new 专案名称 ----新建一个专案
3.cd 专案名称 ----进入你的专案
4.atom ./打开atom,选择 File > Add Project Folder…
----在你的atom中打开专案
5-1.git init ----把repository(repo)初始化到一个叫做 .git 的资料夹
git add . ----告诉 git 你想要把目前资料夹(即 .)还有它底下的所有东西加进repo
git commit -m “xxx” ----告诉 git 真的要执行你叫它做的事
5-2.prepare work
(1).install bootstrap:
在atom修改 Gemfile,在 group :development, :test do前一行加入 gem ‘bootstrap-sass’(#32)
bundle install
mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss
将 application.css 更名为 application.scss
1 | @import "bootstrap-sprockets"; |
(3).提示信息
s1.
1 | ... (一堆注解) |
s2.touch app/views/common/_flashes.html.erb
1 | <% if flash.any? %> |
1 | <%= render "common/flashes" %> |
s4. flash[:alert] = “xxx”
(4).登录系统
s1.gem “devise” –> bundle install –> rails g devise:install –> rails g devise user –> rake db:migrate
s2.
1 | - <li> <%= link_to("登入", '#') %> </li> |
s3.
1 | //= require bootstrap/alert |
(5).安装simple_form
gem “simple_form” –> bundle install –> rails generate simple_form:install –bootstrap
重开sever
1 | <%= simple_form_for @group do |f| %> |
6.rails g model xxx 栏位:字符型
rake db:migrate
rails g controller xxxs
(rails g controller welcome)
CRUD
7.touch app/views/xxxs/index.html.erb
(touch app/views/welcome/index.html.erb)
8.resources :xxxs/root “welcome#index”
----在route.rb中添加路径