Rails 关于 rails4 的 app/models

shallow__pace · June 24, 2013 · Last by martinliu replied at July 11, 2013 · 3291 hits

用脚手架生成了一下代码rails generate scaffold User name:string email:string 然后数据库迁移bundle exec rake db:migrate 查看 rails 项目中的app/models/user.rb,内部代码如下:

class User < ActiveRecord::Base
end

但是railstutorial上 3.0 版本的代码应该如下:

class User < ActiveRecord::Base
  attr_accessible :email, :name
end

本人环境是rails4.0,请问 4.0 中 attr_accessible 部分是移到哪去了,或者说是做了什么改变?

都换成 Strong Parameters 了

Parameters 本来就应该由 Controller 负责过滤,现在它回到该去的地方了。

都 rails4 啦!!各种跟不上的节奏啊。。。去墙角画圈圈了

Unknow user #5 June 28, 2013

#2 楼 @tumayun 这让我想起了 Java 的getset,总觉得有点麻烦

已经变成 Strong Parameters, 放到 Controller 中去过滤了。

Unknow user #7 July 11, 2013

rails 3.2 的路过

You need to Sign in before reply, if you don't have an account, please Sign up first.