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

Ruby

Deleted User

undefined method `full_name' for nil:NilClass

Some one could help me, i got this error undefined method `full_name' for nil:NilClass

9 Answers

I'm stuck at the 'Testing the whole app' > 'Before Filters' video ... I can't get rid of this error when running the ruby -Itest test/functional/statuses_controller_test.rb

1) Error: test_should_get_index(StatusesControllerTest): ActionView::Template::Error: undefined method `full_name' for nil:NilClass

3) Error: test_should_show_status(StatusesControllerTest): ActionView::Template::Error: undefined method `full_name' for nil:NilClass

For others I fixed my issue by running rake db:reset then rake db:migrate. you may have to put bundle exec in front of those commands.

Thank you, you helped solve my issue.

Can you post your full_name method? Maybe a link to a gist of the model?

Deleted User

here is my user model

class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable

# Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name , :profile_name

validates :first_name, :presence => true validates :last_name, :presence => true validates :profile_name, :presence => true, :uniqueness => true, :format => { :with => /^[a-zA-Z0-9_-]+$/, :message => "Must be formatted correctly." }

# attr_accessible :title, :body

has_many :statuses

def full_name first_name + " " + last_name end

def gravatar_url stripped_email = email.strip downcase_email = stripped_email.downcase hash = Digest::MD5.hexdigest(downcase_email)

"http://www.gravatar.com/avatar/#{hash}"

end

end

Deleted User

Dude thanks i fix it, it was a trouble with the db, but thank for your help!

:)

I have the same problem... How did you fix this?

Cheers!

I have the same problem... How did you fix this?

I have the same issue