root to: 'xxx'  默认root路径

Nested Resource:

Rails.application.routes.draw do
resources :books do
resources :notes # , only: [:create, :destroy]
end root to: "books#index"
end

content_tag:

simple_format:  Formats new lines as <br>

Authentication:

has_secure_password 

#bcrypt-ruby(gemfile)
1. run bundle install
2. make sure password_digest is table column
3.account for password inside strong parameters list in the controller

HTTP Sessions and cookies:

HTTP is a stateless protocol:

1.即使来自同一个浏览器的每个新请求都不知道以前发出的请求。

2.这意味着,即使用户发出请求,他在所有后续请求中都将被视为未知。

Cookies and Sessions to the rescue(keep state)

Sessions in rails:

1.rails 中session 以hash形式来传播

2.服务器向浏览器发送一个cookie,其中包含浏览器存储的会话信息,并在所有后续请求(直到会话结束)时将其发送回服务器

Rails.application.routes.draw do
resources :books do
resources :notes, only: [:create, :destroy]
end resources :sessions, only: [:new, :create, :destroy] root to: "books#index"   get "/login" => "sessions#new", as: "login"
  delete "/logout" => "sessions#destroy", as: "logout"
end

session controller:

Authorization:

def logged_in?
session[:reviewer_id] # nil is false
end def current_user
@current_user ||= Reviewer.find(session[:reviewer_id])
end

Pagination:

# include will_paginate gem 

# use in controller 

def index
@books = current_user.books.paginate(page: params[:page], per_page: 10)
end # use in html.erb <%= will_paginate @books %>

ssl: in production.rb,

  uncomment #config.fore_ssl = true

  to use https

最新文章

  1. 详解Java 8中Stream类型的“懒”加载
  2. iOS 底层框架的浅析
  3. java中文文档官方下载
  4. Monkey测试3——Monkey测试结果分析
  5. 8. js中json格式解析
  6. Selinux在HTTP+PHP服务中的安全权限修改
  7. POJ3352 Road Construction(边双连通分量)
  8. Android之adb命令
  9. Qt的gzip模块实现
  10. 1036: [ZJOI2008]树的统计Count - BZOJ
  11. python entry points 例子
  12. 【Alpha阶段】第七次scrum meeting
  13. Linux查看系统中的每个进程
  14. 网易2019校招内推编程题-俄罗斯方块-C++实现
  15. Stacking Plates(存档待续.....(没有写思路和程序))
  16. ruby离线安装整理
  17. openssl rsa/pkey
  18. CDQ分治小结
  19. Linux: 介绍make menuconfig中的每个选项含义【转】
  20. Solr高效利用:Solr实现SQL的查询与统计

热门文章

  1. 【原创】大数据基础之ElasticSearch(3)升级
  2. php判断是不是手机端访问
  3. python---循环双向链表实现
  4. 【Android】自动测试工具 Monkey
  5. 带URL的XML解析方式
  6. React实现局部刷新
  7. Microsoft Office Word 中的公式自动编号
  8. Selenium2+python自动化45-18种定位方法(find_elements)
  9. 识别拖动与点击操作之zepto的bug
  10. PCB资料