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 trialLisa Rossiter
3,630 PointsRails 4 breaks doesnt work with this?
I have tried and tried but rails 4 doesn't have attr accessible so is not putting :first_name, :last_name, :profile_name into the database at all.
4 Answers
Dino Paškvan
Courses Plus Student 44,108 PointsI went digging for an older thread where I offered a solution for this, as well as some other issues you might run into when using Rails 4 with this tutorial. I hope at least some of it helps.
Adam Sackfield
Courses Plus Student 19,663 PointsRails 4 did removed the attr_accessible in favour of adding strong params inside the the controller, something like below.
params.require(:status).permit(:content, :user_id)
For user_id which is later on in your course. But I would highly suggest that you start over and use Rails 3.2 as it will cause more problems for you later down the line if you are not confident Rails. Then once more confident you can attempt again with Rails 4.
Also I would recommend this resource as a great guide to Rails (Has 2 Versions of the guide 3.2 & 4) here
Lisa Rossiter
3,630 PointsI would rather learn the differences between the two the hard way as a lot of the functionality of this tutorial is what I need in my app. Thank you for your answer I will give it a go. I believe treehouse should include directions and notes for rails 4. Can you explain the above code more?
Adam Sackfield
Courses Plus Student 19,663 PointsI am not confident enough in my Rails abilities to guide you on this one, as I am currently trying to learn Rails myself but being bogged down with other projects. If you really want to struggle through with Rails 4 then you should really read the guide I posted above.
Also Google is your best friend here, also statckoverflow will help where up some things and obviously the Rails docs. A key skill in web development is problem solving and finding solutions on your own by trial and error and reading no end of different posts.
Sorry I can't guide you more on this but I would rather you find the answers for yourself, as when you get to user_ids section it will break again and you will then need to research why it is not working all over again.
This is why I suggested starting over with Rails 3.2 as it's a very large course with 3 big parts, that will give you a solid base for understanding Rails, then you may move over to version 4 and just concentrate on what has changed since 3.2.
I would also suggest a read of this it's free and a little surreal to read. Also this book here
Hope this is helpful and good luck with Rails :)
Ryan Duchene
Courses Plus Student 46,022 PointsIf you really, really want to continue building Treebook in Rails 4, you can add this to your Gemfile:
gem 'protected_attributes'
And then run bundle install
. The gem will add attr_accessible
back into the models.
But ultimately, Adam is right. Rails 4.0 has improved a lot of things internally over Rails 3.2, and some things have changed. Gems like Protected Attributes (the gem I had you install) will allow you to continue for awhile, but it'd be better if you either started over with Treebook in Rails 3.2 or switched to building ODOT in Rails 4.0. With the authentication course that got added very recently, building ODOT should teach you a lot of the same functionality that Treebook would.
In fact, I started to build Treebook in Rails 4 and I ran into issues before I even finished the first set of badges. And that's how I know that the Protected Attributes gem exists.