This project is archived and is in readonly mode.
[Feature Request] add :if / :unless conditions for attr_accessible, attr_protected and attr_readonly
-
Kane
those methods are there to control mass-assignment. I cant see any use in deciding if mass-assignment is allowed or not by state. use case?
-
petRUShka
Order created at two step "prebooking" and "book". At prebooking step user set only part of attributes (minimal set of attributes to check whether date is free). And then that attributes can't be changed, because we have limited quotes for hotel at day, and if bad man change, for example, date by mass-assignment we can get an hidden error.
with_options :if => :prebooking? do |c| c.attr_accessor :city, :hotel, :date end with_options :if => :book? do |c| c.attr_accessor :name, :phone, :email c.attr_readonly :city, :address, :date end -
Kane
to deny changes of some attributes related to the current state validators should be used. i think you misuse those methods. they are only there to control mass-assignment, like in controllers.
-
petRUShka
May be you are right
-
José Valim
- State changed from new to invalid
-
Ryan Bigg
Automatic cleanup of spam.