ruby - Rails: list all attributes that can't be mass assinged -



ruby - Rails: list all attributes that can't be mass assinged -

i working through old legacy project has been updated. models project in engine running seperate controllers , views etc. engine running on rails 4.1.6 while controllers etc on rails 3.

this has led many issues mass-assignment. have created little module reads db columns , white lists attributes model. in case such newsitem model has associations , needs take attributes associations, module doesn't work.

class newsitem < activerecord::base include myattraccessiblemodule has_and_belongs_to_many :assets has_and_belongs_to_many :boroughs has_and_belongs_to_many :venues

i need add

attr_accessible :asset1_attachment_remove, :asset1_attachment_title, :asset2_attachment_title, :asset3_attachment_title, :asset4_attachment_title, :borough_ids, :venue_ids

but finding models require bit of pain, seeing there on 100.

is there way highlight, find, test, find in other models error might occur in also?

cheers

i think you're looking this:

object.attributes.keys - object.accessible_attributes

this should subtract whitelisted attributes of available ones.

ruby-on-rails ruby ruby-on-rails-3 rspec

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -