Questions tagged [attr-protected]
9 questions
113
votes
8 answers
Elastic Search: how to see the indexed data
I had a problem with ElasticSearch and Rails, where some data was not indexed properly because of attr_protected. Where does Elastic Search store the indexed data? It would be useful to check if the actual indexed data is wrong.
Checking the…

Robin
- 21,667
- 10
- 62
- 85
8
votes
3 answers
Setting protected attributes with FactoryGirl
FactoryGirl won't set my protected attribute user.confirmed. What's the best practice here?
Factory.define :user do |f|
f.name "Tim" # attr_accessible -- this works
f.confirmed true # attr_protected -- doesn't work
end
I can do a…

brittohalloran
- 3,534
- 4
- 28
- 27
2
votes
4 answers
Ruby on Rails attr_protected
I have the following code in my User model:
attr_protected :email
I'm trying to create a new user object, but I get a mass assignment protected error with the following code.
user = User.new(
:first_name => signup.first_name,
:last_name =>…

Brian
- 5,951
- 14
- 53
- 77
2
votes
1 answer
Manipulating attributes from a namedtuple() derived class
I have a class called EasyUrl() that is derived from urlparse.Parseresult(). ParseResult() is instantiated when calling urlparse.urlparse(url), I have a static method inside EasyUrl() that changes the class type of the instantiated ParseResult()…

Brandon Nadeau
- 3,568
- 13
- 42
- 65
2
votes
2 answers
Assignment of a protected attribute in Rails
I have a field on my User model that is protected because it determines clearance level. So it should be left protected and not mass-assignable. So even though attributes are protected by default in 3.2, that is actually the behavior I…

Jonathan Allard
- 18,429
- 11
- 54
- 75
1
vote
1 answer
Asset Helper and protected View _scripts in CakePHP 2.0
After upgrading to 2.0 many "hacks" like accessing protected attributes are not possible anymore.
For example (AssetHelper):
$scripts = $this->View->_scripts;
//pack and return combined scripts
The helper fatal errors, of course.
Does anyone know…

mark
- 21,691
- 3
- 49
- 71
1
vote
1 answer
attr_protected equivalent for Rails 6? gem protected_attributes needs activemodel < 5.0 and hence is not compatible for rails 6
Searching for an 'attr_protected' equivalent for Rails 6
gem protected_attributes which served the purpose from rails 4 onwards, needs activemodel < 5.0 and hence is not solving for rails 6.
Any alternatives or better solution for achieving the…

Bivil M Jacob
- 471
- 4
- 9
1
vote
1 answer
What happened to build() in Ruby on Rails 5
I'm working with nested forms in Rails 4 / 5. Code that used @my_model_instance.build in Rails4 doesn't seem to work in Rails 5. I'm not sure if this is a bug or if its me.
Details:
Rails 4.2.3 console:
> @item = ItemType.new
=> #

gramsay
- 11
- 4
-2
votes
2 answers
attr_protected Rails 4
Hello I tried To use attr_protected on Rails 4 but I couldn't.
It's say attr_protected is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add protected_attributes to your Gemfile to…

Murat KAYA
- 23
- 7