I have the following on an index.htm.erb file which includes the
<%= link_to user.first_name + ’ ’ +
user.last_name, user, :class=>‘first_and_last_name’ %>
The problem here is that user.first_name and user.last_name are empty.
If I remove it and replace it with “show” or whatever it works fine.
So I know why it’s not working, it’s because there is no first name or
last name set. How can I make it work when user.first_name and
user.last_name are empty? Kinda like replacing it with “no name”?
NoMethodError in Users#index
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.+