Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby

Ruby question about 'models' directory and using scaffolds correctly

Hello fellow programmers (yes, even you learning, YOU'RE a programmer, too!)

So I'm doing the "Build a Simple Rails App" course, and I am on the Generate a Rails Application lesson.

In it, we do rails generate scaffold status name:string context:text

Then we go into our text editor, and go to the models directory and to our status.rb file.

Our great teacher Jason Seifer shows how we should have

class Status < ActiveRecord::Base
    attr_accessible :context, :name
end

Bingo, easy. Except that I only have;

class Status < ActiveRecord::Base
end

I will add in the rest, but howcome his is adding it in automatically and mine is not? He is using different versions, and he also used the rvm 1.9.3 before creating the application. I read on the lesson that rvm use is not required in Windows, yet I am unaware if this has anything to do with why mine won't work automatically, or if I understand the process properly enough to see a fix.

Good ol' Jason Seifer. He's great to watch. I hope he sees this post, as he's a great teacher.

1 Answer

David Gross
David Gross
19,443 Points

if you check your StatusesController < ApplicationController it under private status_params method . They updated attr_accessor to strong params for security reason in rails 4.0.

def status_params
  params(:status).permit(:context, :name) 
end