No more attr_accessible in Ruby on Rails 4
来源:互联网 发布:groovy web编程 编辑:程序博客网 时间:2024/05/16 19:43
In a file called list.rb, I had
attr_accessible :title, :user_id, :updated_at, :created_at
When you run the tests using 'edge' Rails (4.0.0 beta), you get an error like this: "`attr_accessible` is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add `protected_attributes` to your Gemfile to use old one."
What does this mean? This blog tells you:
http://logicalfriday.com/2012/10/15/sneaking-a-peak-at-rails-4/
Remove the attr_accessible line from your models. In each of the controllers, add at the bottom something like this (for example, this islist_controller):
private def app_params params.require(:list).permit(:title, :user_id, :updated_at, :created_at) end
and, where you create a new list in the controller (thecreate method), instead of
@list = List.create(params[:list])
you should have
@list = List.create( app_params )转自:http://rubyjunction.us/no-more-attr-accessible-in-ruby-on-rails-4
- No more attr_accessible in Ruby on Rails 4
- MVC in Ruby on Rails
- RESTful in ruby on rails
- Ruby on Rails (4)
- connect to Oracle in Ruby on Rails.
- Ruby on rails plugin in eclipse
- Ruby on Rails in Ubuntu12.04
- Ruby On Rails 4 hello world,Ruby On Rails上手
- Ruby on rails: no such file to load -- openssl
- Ruby & Rails on Rails 進階書單
- ruby and ruby on rails
- install Ruby on Rails
- Ruby on Rails 实践
- Ruby on Rails!
- Ruby on Rails
- 关于Ruby on Rails
- 初探Ruby on rails
- Ruby on Rails
- 解决ip地址冲突
- SecureCRT 实用配置
- Powerdesigner15-用jdbc链接MySQL实现逆向工程步骤
- vbs 写txt日志
- 关于matlab函数bwmorph函数的C++版本
- No more attr_accessible in Ruby on Rails 4
- wince 8 一如既往
- JS怎么刷新当前页面
- 在linux环境下实现定时计划任务
- arcgis 批量裁剪工具
- VS2008快捷键大全
- JQuery音视频播放插件Jplayer
- Linux程序设计入门
- Linux设备驱动程序学习(3)-字符设备驱动程序