> Hello people,
>
> I am developing an app with Rails 4.0.x and I have a strange bug in its
> view. Say I have a partial like this
>
> %p= @bject,name # would work perfectly
Does using @object,name also work (not @bject which you have written
above)?
Actually the variable name is not @Object. Its some thing else. Have
checked spelling, copied and pasted it. But nope. It won't work.
>
> = render @object.friends # It won't fetch this relation
What do you mean it will not fetch the relation? What is the error
message?
There shows no error, it just returns nil object. If I give @
obj.friends.first.name , it would say undefined method first for nil object!
>
> %p= @object,name # It would say can't find name for nil class
Then @object is nil. Perhaps you should be using @bject.
Note that when posting code it is better to copy/paste then there will
be no confusion about what the code actually is.
Yup copied, pasted and banged my head on desk a 1000 times.
Say if in the action if I keep @object2 = Person.find params[:id] and if I
use @object2 in code, it works perfectly everywhere. This bug is repeatable
on server and my local system running ruby 2.1.0 and Rails 4.3.
Some how rails is forgetting what @object is in the middle of view.
For some reason the above stuff happens. However in the rails console, all
would work fine. Kinda confused.
Would be great if any one could throw light on this. Don' know if this is
a
Rails bug where state of instance variable gets forgotten after some time.
My experience is that bugs in compilers/frameworks/OSs are very rarely