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
fabricio mattos
4,897 PointsProgramming > Build a Simple Ruby on Rails Application > Customizing Forms > Creating Relationships error first_name == nill
Hi Folks,
I'm having some issue with the first_name field . I saw in the forum that other people had the same problem but the all cases the issue was the number the id was wrong.
In my case I know the number the id of the pk field in the User Table, the problem is that the foreing key user_id in the Status table is nill even after I update the form.
I saw the lesson three times and did the steps again but is not working.
What could be.
PS: I'm using rails 4 and the only difference that I noted was the method "attr_accessible" is not accessible when I installed the device gem , so I installed the gem "attr_accessible" in the Gem File.
2 Answers
Alan Johnson
7,625 PointsCan you share your code from statuses_controller.rb?
Alan Johnson
7,625 PointsFrom what I can tell, you're not ever setting up the user relationship on the status. What if you put something like:
@status.user = current_user
after you create the status, so create would look like:
def create
@status = Status.new(status_params)
@status.user = current_user
...
Josh Flowers
7,010 PointsWhere exactly would you inject that? I seem to have the same problem, my code is the same as fabricio mattos
fabricio mattos
4,897 Pointsfabricio mattos
4,897 PointsHi Alan ,
This is my statuses_controller.rb
fabricio mattos
4,897 Pointsfabricio mattos
4,897 PointsHi Folks, What can I do to fix this issue?
Thanks
Fabricio