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
Joseph Buczek
4,082 PointsRuby in context
I'm almost done with the Ruby essentials training, but I'm having some issues understanding the context in which Ruby is used.
To better illustrate what I'm saying, I'll use an contextual example of something I already understand: VBA in MS Excel. Within an Excel workbook, I code VBA to manipulate and work with Excel spreadsheets and other objects within Excel. I know that I can attach VBA to objects in a spreadsheet, and I can manipulate and format the data on the spreadsheet. The context of VBA within Excel is apparent to me, because I know where and what I'm working with.
With Ruby, I haven't quite grasped the context in which it can be used. Perhaps this is explained later, but the fact that I don't yet grasp the context is preventing me from fully understanding what I'm trying to learn here.
Can someone provide actual, real-life contextual examples of where and why Ruby is used?
2 Answers
Ken Alger
Treehouse TeacherJoseph;
Great questions. Ruby is used to program many different applications. Ruby on Rails, Rails, is a back-end web framework. There are a multitude of other frameworks written in Ruby as well, here is a partial list. Similarly, there are back-end frameworks written in other languages, like PHP and Python for example.
Let's take a look at Rails in general from a very high level. Rails is follows the Model-View-Controller (MVC) model of frameworks which allows for more rapid development of applications. Since Rails in written in Ruby, from a programming standpoint it is Ruby that controls the flow of information on the site.
With regards to a couple of your specific questions, and hopefully the others will make sense after...
Is it generating HTML content? Probably not in the way you are thinking. In an MVC modeled framework, HTML falls into the View construct. The HTML is the structure of the view as laid out by the web designer. Ruby is used to fill in dynamic content based on the needs/wants/desires of the user. From a View standpoint Rails provides the necessary information for the view to display.
Is it processing something? Yes, Ruby processes lots of things in Rails. For example on this website in the forum when you select on a subject matter on the right side, say "Ruby", the Controller sends a request to the database (Model) for all forum posts that have been tagged with the "Ruby" subject matter. It then sends that data back and gets presented in the View.
Treehouse offers several discussions which provide overviews of Frameworks and MVCs, the one that makes the most sense to me is in the Laravel Basics Course in the first module. It is well worth the 3:20 to take a look at the video.
I probably raised more questions than answers, but hopefully I helped in some way.
Ken
Ken Alger
Treehouse TeacherJoseph;
One example is the Ruby on Rails framework. Treehouse uses Ruby on Rails for this website. Ruby is, of course, used in many other areas of programming.
Ken
Joseph Buczek
4,082 PointsKen,
I appreciate your response, however it still leaves me without a good sense of ~how~ it's used for this website. Is it generating HTML content? Is it processing something? Is it simply constructing the pages and doing nothing after that? And if there is user interaction, how is Ruby on Rails listening for input? So far all I've seen is command line programs.
Thanks, Joey
Joseph Buczek
4,082 PointsJoseph Buczek
4,082 PointsThanks for the explanations! I think this helped put me into the right frame of mind.
So essentially, Ruby/Rails is handling the back-end processing of the user's interactions with the site, and then displaying the results for the user to continue to interact with, correct? I'll check out that video as well.
I'm the type of person that really needs to understand the 'why' behind anything, then everything starts to fall into place.
Ken Alger
Treehouse TeacherKen Alger
Treehouse TeacherJoseph;
From a high level, yes. As you can imagine, there is a lot more going on but Rails essentially "just" handles the back-end processing, and happens to be written in Ruby.
The video link I provided is in a course on Laravel which is an MVC framework programmed in PHP. Very similar, just a different language.
Again, don't get locked into thinking that Ruby can only be used for web frameworks, it is much more versatile than that. I just chose Rails as an example since Treehouse's site is based on Rails so you could relate to it a bit.
Ken