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

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