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!

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

Dave Faliskie
Dave Faliskie
17,793 Points

Ruby on Rails update & difference with attr_accessible.

Im following along with the "build a simple Ruby on Rails Application" I noticed that models/status.rb file does not include the attr_accessible line. I don't fully understand what its for but I believe its to allow the user to use something on the server, or grant access in some way. I am using the most current version of ruby and was wondering if anyone knew if this is a change because of versions, or why attr_accessible doesn't work.
Any information on this would be very helpful!

1 Answer

Roberto Alicata
PLUS
Roberto Alicata
Courses Plus Student 39,959 Points

Rails 4 now uses strong parameters and protecting the attributes is now a job of the Controller.

example:

class PeopleController < ApplicationController
  def create
    Person.create(person_params)
  end

  private

  def person_params
    params.require(:person).permit(:name, :age)
  end
end