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

Naomi Freeman
STAFF
Naomi Freeman
Treehouse Guest Teacher

Got friendships working, now content doesn't show

Any thoughts on what I possibly could have accidentally undone that would make all the user friendships and relationships work, but no longer load the status content in the Treebook social features project? I'm at the end of AJAX.

It is saving and creating the status and deleting it. On the view statuses page, it is showing the user, gravatar, time it was posted - it just no longer shows the content of the status. And when you hit "edit", the content of the status is not there.

Yes, I tried dropping, creating and migrating my database.

What did I break guys? Thanks!

Can we see your controller and view.

Naomi Freeman
Naomi Freeman
Treehouse Guest Teacher

When I click "Post a new status" this is what happens in the terminal:

Started GET "/user_friendships.json" for 127.0.0.1 at 2014-02-13 13:28:03 -0500 Processing by UserFriendshipsController#index as JSON User Load (1.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1 DEPRECATION WARNING: Relation#all is deprecated. If you want to eager-load a relation, you can call #load (e.g. Post.where(published: true).load). If you want to get an array of records from a relation, you can call #to_a (e.g. Post.where(published: true).to_a). (called from index at /Users/naomifreeman/Projects/laughing-wookie/app/controllers/user_friendships_controller.rb:6) UserFriendship Load (0.6ms) SELECT "user_friendships".* FROM "user_friendships" WHERE "user_friendships"."user_id" = $1 [["user_id", 1]] Completed 200 OK in 7ms (Views: 0.2ms | ActiveRecord: 1.7ms)

On my page, it sends me the message that the post was successfully created, but doesn't show the content. Not sure what is up. This json/AJAX stuff is really new to me.

In other strange things not working in my app: I can't get the friend gravatar_url to work in views > user_friendships > index. User does, but it yells at me no matter what combo I try with friend.

1 Answer

Naomi Freeman
STAFF
Naomi Freeman
Treehouse Guest Teacher

Got it :)

In the controllers - user_friendships, at the bottom def status_params params.require(:status).permit(:content, :profile_name, :full_name, :user_id, :first_name, :last_name) end

I had accidentally deleted .require(:status)

For others' future reference: this def status_params stuff is instead of attr_accessible

It's been fine in my code all along. Just as I was changing things up, I guess this accidentally happened.

So most things seem to be working now. The thing that is not is all the friend.gravatar_url stuff and friend.full_name. I've got it saying the profile name with just friend but when I try and add .gravatar_url, .first_name, anything like that, it's telling me

undefined method `full_name' for nil:NilClass

--

Also, just playing with it, somehow my users can still delete each other's statuses :(