分类目录
-
近期文章
近期评论
- Dillon 发表在《Mac OS代理工具Proxifier》
- RobertFluch 发表在《Bash Shell 快捷键》
- brew 不可用,重新安装 发表在《Mac下删除自己安装的Python》
- 子陵 发表在《Mac下删除自己安装的Python》
- Yucun 发表在《Mac下删除自己安装的Python》
文章归档
标签
7-zip 7zx active record CentALT cookie crontab dreamhost eclipse EPEL fast GarageBand google hyk-proxy LITTECMS mail mysql2 MySQLdb netgear nginx office PIL ports Proxifier pydev python readability requests sleep timeout torrent ubuntu unicorn urllib2 urlopen web.py yum zoc 下载 二笔 亿恩科技 吉他 睡眠 编码 路由 郑州景安
Daily Archives: 2013-09-12
捕获 ActiveRecord::RecordNotFound 输出 404 页面
class ApplicationController < ActionController::Base protect_from_forgery with: :exception rescue_from ActiveRecord::RecordNotFound, with: :render_404 protected def render_404 render(file: “#{Rails.root}/public/404.html”, :layout => false, :status => 404) end end
Rails 4 Tip
RAILS_ROOT 被 Rails.root 替换 ActiveRecord 的 White list attributes 被 Strong Parameters Gem 替换 如果使用了 accepts_nested_attributes_for 应当如下使用 `Strong Parameters` Class User accepts_nested_attributes_for :profile end # strong parameters params.require(:user).permit(:name, profile_attributes: [:xxx, xx])
Posted in ruby on rails
Leave a comment