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 trialHassan Al-ubeidi
Courses Plus Student 6,035 PointsUser status relationship bug
Followed the video exactely, but still manage to get this error, whatever user_id I use.
NoMethodError in Statuses#show
Showing C:/Sites/treebook2/app/views/statuses/show.html.erb where line #4 raised:
undefined method `first_name' for nil:NilClass
I've kind of narrowed down the bug to the fact that when signing up, the user is still not getting a first name or last_name assigned to them
5 Answers
Hassan Al-ubeidi
Courses Plus Student 6,035 PointsYup, the problem was the version of Ruby I was using at the time. This appears to be a common problem with people following that tutorial. Would be nice if treehouse could put up a note telling you that it is in Ruby 3.2 and that using Ruby 4.0+ will cause problems, or hell updating the tutorial would be great.
Lisa Rossiter
3,630 PointsYou need push your app to git hub :)
Lisa Rossiter
3,630 PointsYou know you mentioned that first and last name are not getting assigned. Have you checked that your strong parameters for devise are updated accordingly. Check out the devise strong parameters documentation and you need to put it in your application.rb. If you push an update to git hub I can check for you
Seph Cordovano
17,400 PointsIf it helps, my application controller finally looked like this (which goes along with what Lisa is saying) after quite a number of hours of debugging this is issue and not much help from the Treehouse forums.
app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
before_filter :update_sanitized_params, if: :devise_controller?
protect_from_forgery with: :exception
end
def update_sanitized_params
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:profile_name,
:email, :first_name, :last_name, :password) }
end
Lisa Rossiter
3,630 PointsWhen you go to edit a user is their names in the fields?
Lisa Rossiter
3,630 PointsAlso your github is still not up to date?
for example your show page is still
<p id="notice"><%= notice %></p>
<p>
<strong>Name:</strong>
<%= @status.name %>
</p>
<p>
<strong>Content:</strong>
<%= @status.content %>
</p>
<%= link_to 'Edit', edit_status_path(@status) %> |
<%= link_to 'Back', statuses_path %>
Hassan Al-ubeidi
Courses Plus Student 6,035 PointsWelp, guys it appears that the problem is that I'm using Ruby 4.1, while the tutorial videos use Ruby 3.2. I'm going to uninstall everything and start fresh but with Ruby 3.2 and see how it goes.