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 trialfirnaz luztian adiansyah
5,295 Pointsundefined method `attr_accessible' for #<Class:0x77e25d0>
help! I did exactly the same I followed the steps in the video, i did migrate the db but I keep getting this error when I go to localhost:3000/statuses
NoMethodError in StatusesController#index
undefined method `attr_accessible' for #<Class:0x77e25d0>
2 Answers
Maciej Czuchnowski
36,441 PointsThis course uses Rails 3.2. If you're using Rails 4 and above, the code shown in the videos will not work (it's outdated). attr_accessible is one of the differences. Rails 4 uses Strong Parameters instead for this purpose.
Nelly Nelly
7,134 PointsI just face into this problem maybe this could help !
Using Rails 4 the solution is to create a controller for user_friendships ( in the next video Jason create that controller, so you will need it anyway)
rails g controller UserFriendships
`
And set the strong parameters :
class UserFriendshipsController < ApplicationController
private
def params_user_friendship
params.require(:friendship).permit(:user, :friend, :user_id, :friend_id)
end
end
firnaz luztian adiansyah
5,295 Pointsfirnaz luztian adiansyah
5,295 PointsSorry I am new to rails does that mean we can fix this with replacing attr_accesible with strong parameter? how? I was about to downgrade to 3.2.
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsIt's better to downgrade to 3.2 and use old gems like Jason does. Trying to translate this app into Rails 4 is not so easy if you're new to Rails.