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
Stephen Printup
UX Design Techdegree Student 45,252 PointsComputer Science: How are variables stored?
So, I am interested in creating a in-house web app that I can host on my work's server that includes widget type features including a in/out indicator for staff and also a quasi-message board (similar to a forum, but more like a newsletter).
The message board would have a text input with a update button, like a task list and the layout would be a single column. As the user goes down the page, each div would represent a different department so the organization could be updated on what's happening.
My question is, would it be possible to code something like this using ruby and store the information in variables (is this RAM, which would be deleted with every new session) or PHP (which would be tougher for me, but would offer SQL)? It's not too complicated of a project, but I guess I see a difference in how information is stored on the machine and am looking for a bit of a discussion. Thanks for any input.
-Stephen
3 Answers
Tyrell Jentink
8,415 PointsYou nailed the debate right on the head... If you need permanency, than you need SQL (Or files on written to the disk, but that's not terribly efficient). Variables are really only useful while the program is running, and with a web application, that's usually for a few fractions of a second. Session type variables can be stored in a MySQL database, but are often just stored client-side in cookies or as a parameter passed through the URL.
I've been doing PHP, so I know how I'd approach it that way... But doesn't Ruby on Rails give you the same capabilities of interacting with a SQL database?
Stephen Printup
UX Design Techdegree Student 45,252 PointsThanks guys! I'm piecing it all together and appreciate the advice.
Stephen Printup
UX Design Techdegree Student 45,252 PointsOk,
So this is the page I'm trying to build the backend for:
http://www.stephenprintup.com/nayamessageboard/
I'm thinking of doing the employee in/out section and room section as per: http://teamtreehouse.com/library/ajax-basics
I'm not sure if there is a maximum length for variables, but obviously this section would require a bit more than an array. So I was thinking of maybe doing SQL/PHP for the middle section. Do you have recommendations for linking up the middle? Do you know what wordpress uses to accomplish the same task? The page will be hosted on a intranet, so security won't be an issue.
Finally, I'm not sure how I could upload the PDFs, so any advice in this section would be much appreciated. I was thinking of integrating Ruby to upload the links on the right section into the unordered list (similar to a todo list), so maybe this same technique could work for PDFs as well? Or are there better ways?
As you can see I've got ideas of how to build the backend of this page, but could use some guidance as to what best practices are. Thanks in advance for any help.
-Stephen
Ricky Catron
13,023 PointsRicky Catron
13,023 PointsYou are correct both PHP and Ruby/Rails allow for storage in a database. I would use MySQL myself. If he wants any kind of storage he wants a database.
--Ricky