Ruby on Rails
Tuesday, April 1, 2014
Ya possibly. Any way did a work around. Thanks a lot for your replies.
On Wed, Apr 2, 2014 at 12:19 AM, Matt Jones <al2o3cr@gmail.com> wrote:
On Tuesday, 1 April 2014 06:50:20 UTC-4, Karthikeyan A K wrote:On Tue, Apr 1, 2014 at 2:04 PM, Colin Law <cla...@gmail.com> wrote:
On 1 April 2014 06:11, Karthikeyan A K <77m...@gmail.com> wrote:Does using @object,name also work (not @bject which you have written above)?
> 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
Actually the variable name is not @Object. Its some thing else. Have checked spelling, copied and pasted it. But nope. It won't work.
What do you mean it will not fetch the relation? What is the error message?
>
> = render @object.friends # It won't fetch this relation
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!
Then @object is nil. Perhaps you should be using @bject.
>
> %p= @object,name # It would say can't find name for nil class
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.I'm going to assume the "3" in "4.3" is a typo - otherwise, say hi to the future people for me. :)Anyways, the usual cause of weird name-specific behavior is that you've picked a name which is used internally by part of Rails. Sanitizing your example to "@object" rather than the real name is going to make this difficult to troubleshoot...--Matt Jones--To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/fb0a6dae-cf7d-41b7-87a0-816ed485065e%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/UaWUMHoGo90/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJR%2B9kZRCvriqjdUgnwdVUgJeFOL6ZRs4q3Bm66fAjPekGxaGg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment