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 Build a Simple Ruby on Rails Application Getting Started with Rails Generate a Rails Application

laurie gloge
laurie gloge
8,593 Points

rails generate scaffold status name:string content:text

When I open the status document in my text editor, it seems to work but "attr_accessible: :content, :name is missing, it only shows two lines.

class Status < ActiveRecord::Base end

The file inside of the migrate directory looks fine. class CreateStatuses < ActiveRecord::Migration def change create_table :statuses do |t| t.string :name t.text :content

  t.timestamps
end

end end

Do I need to do something different?

This is what my terminal showed: rails generate scaffold status name:string content:text invoke active_record create db/migrate/20140513231423_create_statuses.rb create app/models/status.rb invoke test_unit create test/models/status_test.rb create test/fixtures/statuses.yml invoke resource_route route resources :statuses invoke scaffold_controller create app/controllers/statuses_controller.rb invoke erb create app/views/statuses create app/views/statuses/index.html.erb create app/views/statuses/edit.html.erb create app/views/statuses/show.html.erb create app/views/statuses/new.html.erb create app/views/statuses/_form.html.erb invoke test_unit create test/controllers/statuses_controller_test.rb invoke helper create app/helpers/statuses_helper.rb invoke test_unit create test/helpers/statuses_helper_test.rb invoke jbuilder create app/views/statuses/index.json.jbuilder create app/views/statuses/show.json.jbuilder invoke assets invoke coffee create app/assets/javascripts/statuses.js.coffee invoke scss create app/assets/stylesheets/statuses.css.scss invoke scss create app/assets/stylesheets/scaffolds.css.scss

2 Answers

Stone Preston
Stone Preston
42,016 Points

you are most likely using rails 4 (you can check by typing rails -v in terminal).

rails 4 uses something called strong parameters that is enforced at the controller level, not the model level like attr_accessible. So thats why that line is missing. It probably wont affect anything right now so at this point the app probably functions fine.

However, If I were you, I would uninstall rails 4 and install rails 3.2 which I think is what is being used in the treebook videos (could be wrong but its definitely not rails 4 though) and start over using the older version. If you dont, you are going to run into some issues which can be resolved, but might take some time for you to fix due to this version difference (lots of googling errors, looking up stuff on the forum here etc).

$ gem uninstall rails
$ gem uninstall railties
$ gem install rails -v 3.2.0

Like I said you can definitely do it using rails 4, but the videos walk you through using the older rails version, not rails 4, so if you encounter problems, you are going to be on your own.

laurie gloge
laurie gloge
8,593 Points

Done thanks will give it a try.