提交 621eb3b6 编写于 作者: J Joost Baaij

Expanded rdoc about primary keys being protected from mass assignment.

People need to make sure they are generated internally or added to attr_accessible so they can be mass assigned (for instance, from an import job).
上级 693a68f2
...@@ -44,7 +44,8 @@ def dangerous_attribute_method?(method_name) ...@@ -44,7 +44,8 @@ def dangerous_attribute_method?(method_name)
end end
# Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the # Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the
# primary_key_prefix_type setting, though. # primary_key_prefix_type setting, though. Since primary keys are usually protected from mass assignment,
# remember to let your database generate them or include the key in +attr_accessible+.
def primary_key def primary_key
@primary_key = reset_primary_key unless defined? @primary_key @primary_key = reset_primary_key unless defined? @primary_key
@primary_key @primary_key
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册