Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Wilson Usman
35,206 PointsNoMethodError in Statuses#new
Here's what's happening when I try creating a new status:
Showing /Users/Wilson/Projects/treebook/app/views/statuses/_form.html.erb where line #14 raised:
undefined method `+' for nil:NilClass
</div>
<% end %>
<%= f.input :user_id, collection: User.all, label_method: :full_name %>
<%= f.input :content %>
<div class="form-actions">
<%= f.button :submit %>
If I change it to :first_name, it works like a charm.
Here's what the user.rb file looks like:
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :first_name, :last_name, :profile_name, :email, :password, :password_confirmation
has_many :statuses
def full_name
first_name + " " + last_name
end
1 Answer
Jason Seifer
Treehouse Guest TeacherDo all of your users have a first_name attribute set? That may be what's breaking it.