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

Matthew Gomez
Matthew Gomez
395 Points

When using Rails 4. You need to tweek the code a bit.

  1. So the first step is adjusting your create method in statuses. When we create a status, we want to make sure the status know to attach itself to a user. your first few lines should look like this:

def create @status = Status.new(status_params) @status.user= current_user //this is the new stuff, so in your "_form" file now, the code knows what you mean when you say "user".

  1. Now we need to allow the user_id to be permitted. right now we only allow name and content. So to do that, at the bottom, your permitted params method should look like this:

def status_params params.require(:status).permit(:user_id, :content) end

  1. So far so good, but we need to manual associate the then last step is to adjust the status model! This associates the user model to the status model:

class Status < ActiveRecord::Base belongs_to :user end