Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can set 'attr_accessible' in order to NOT allow access to ANY of the fields FOR a model using Ruby on Rails?

If in a model file I have just this code:

class Users < ActiveRecord::Base
end

what this means? All attributes related to the model are accessible or not?

How I can set 'attr_accessible' in order to not allow access to any of the fields for that model?

like image 910
user502052 Avatar asked Jan 29 '11 17:01

user502052


1 Answers

Just set:

class Users < ActiveRecord::Base
  attr_accessible #none
end

Like Pan Thomakos said (attr_accessible is the array of parameters that can be mass-ret. So if you send in no symbols, then no parameters will be accessible.

This ticket was useful

like image 171
Jesse Wolgamott Avatar answered Oct 22 '22 15:10

Jesse Wolgamott