undefined method for nil:NilClass in my Rails app -


i'm getting a:

undefined method `lat' nil:nilclass 

error , want solve it. exact message is:

nomethoderror in static_pages#faq  showing /home/christophecompaq/pop/app/views/layouts/_signed_in_header.html.erb line #101 raised:  undefined method `lat' nil:nilclass extracted source (around line #101):  98: <div id="javascript_tags lat , lang"> 99:   <%= javascript_tag %> 100: user_latitude = "<%=raw @user.lat %>"; 101: user_longitude = "<%=raw @user.lng %>"; 102:  103:    <% end %> 104:  </div> 

i have 2 other pages in static pages folder error - 'contact us' , 'about us'.

but when take code below out of _signed_in_header.html.erb , paste in file called show.html.erb, errors stop.

 <div id="javascript_tags lat , lang">   <%= javascript_tag %>  user_latitude = "<%=raw @user.lat %>";  user_longitude = "<%=raw @user.lng %>";      <% end %>   </div> 

but thing is, need have code in _signed_in_header.html.erb.

so suppose question is, 'where can define user_latitude = "<%=raw @user.lat %>" , user_longitude = "<%=raw @user.lng %>" pages recognise them without giving me errors?' i've tried application controller, static pages controller, i'm still getting problems. maybe have put in routes file, i'm not sure? help.

you have controller method defined @user instance variable -- static_pages#faq.

what's happening @user equal nil when passed view. when try send lat method, generates undefined methodlat' nil:nilclass` error.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -