0

I have a problem with attr_accessible and attr_accessor.

When I use attr_accessor in model:

attr_accessor :crop_x, :crop_y, :crop_w, :crop_h

attr_accessible :title, :author, :description, :price, :attach

Error:

Server return:
WARNING: Can't mass-assign protected attributes for Product: crop_x, crop_y, crop_w, crop_h

I edited as follow:

attr_accessible :title, :author, :description, :price, :attach

attr_accessible :crop_x, :crop_y, :crop_w, :crop_h

Error:

Server return:
undefined method `crop_x' for #<Product:0x007fe900f88c20>

So, I used both attr_accessible and attr_accessor:

attr_accessor :crop_x, :crop_y, :crop_w, :crop_h

attr_accessible :title, :author, :description, :price, :attach

attr_accessible :crop_x, :crop_y, :crop_w, :crop_h

But server run forever.

RAM
  • 2,413
  • 1
  • 21
  • 33
yagi_chan
  • 13
  • 6

1 Answers1

0

attr_accessor provides the setter and getter methods for attribute. attr_accessible says that the attribute can be mass-assigned.

deepthi
  • 685
  • 3
  • 9