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 trialMaryAnn Eleanya
8,626 PointsIf I didn't want to use the save content option, how would i save it to a database instead of to a file using sqlite3?
??
2 Answers
Jay McGavren
Treehouse TeacherYou can find info on using Sinatra with ActiveRecord and sqlite3 here: http://recipes.sinatrarb.com/p/models/active_record
I'd advise completing our Rails 5 Basics course before attempting to use ActiveRecord, though.
MaryAnn Eleanya
8,626 PointsAnd how can I do that? Is there anyway to see an example? I just want to create a simple database using Sinatra without having to save to a file.
Jay McGavren
Treehouse TeacherThe example code is there on the http://recipes.sinatrarb.com/p/models/active_record page. You place all the code in one file and run it. But you'll need to install the ActiveRecord gem first. In order to be able to do that, you'll need to understand how Ruby Gems work. You'll also need to create the database and set up tables manually.
I'm afraid there's nothing simple about a database. If you don't understand ActiveRecord, you'll run into problems that you won't know how to solve (and that people on here will not be able to help you with) almost immediately. I would strongly recommend completing as many of our Rails courses as possible before attempting this.
MaryAnn Eleanya
8,626 PointsMaryAnn Eleanya
8,626 PointsAnd to generate a scaffold on sinatra, would I still run bin/rails ...e.t.c or would I need it to name it something else.
Jay McGavren
Treehouse TeacherJay McGavren
Treehouse TeacherActive Record is just one small part of Ruby on Rails, and it does not include the ability to generate scaffolds. You will still need to write all of your Sinatra code manually.