Hello to my fellow rails devs.
I’m currently receiving an “undefined method `location’ for
nil:NilClass” exception error in one of my views when the user hasn’t
filled in the form for their profile.
How would I approach bypassing this error in the cleanest way?
I’ve tried to use the method below, but the error still persist.
<% if @user.profile.location.nil? ? "" : @user.profile.location %> <% end %>
<% if @user.profile.location.present? %>
<% end %>