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

Save checkbox status on rails app

Hello - I'm creating a basic webapp, and I'm using the techniques that I learned here, so what I whant to know is how to save a checkbox status to database.

I'm using scaffolding as in course any ideas?

Regards

1 Answer

(Very) quick rundown:

Generate new rails app:

 rails new checkbox_app

Switch to the app directory:

 cd checkbox_app

Generate Scaffold

 rails generate scaffold Mood happy:boolean

Remove default welcome page

rm public/index.html

Route root to Moods#index in config/routes.rb (in a text editor)

root to: 'moods#index'

Run the migration:

rake db:migrate

Start the server

rails s

…and got to http://0.0.0.0:3000/, you're up and running :)

Chances are, you have a running rails app but no idea how you got there (I've been there). I recommend learning the MVC architecture in depth, here on treehouse, with Michael Hartl's free book and with the Rails Guides.