Site Building With Ruby

According to BuiltWith.com, more than one million currently live websites were built on Ruby on Rails. While not an overwhelming market share, one million sites seem to agree with the sentiment that building a site with Ruby on Rails is an effective and modern way to build a website, and I am here to argue that it is also easy to get started.

Ruby on Rails projects can be started from your terminal and worked on from your favorite IDE or a text-editor like Atom. Once you confirm that your local machine has a version of ruby (you can check this using the command: ruby -v from your terminal), you should be ready to get started with the long and arduous process of getting all the software downloaded you will need to start building your website:

This command will begin installing the necessary files to create Ruby on Rails projects

Not so bad so far, but surely the process of actually using this framework to get a site started is restrictive, or else everyone would be doing it, right? From here you begin a new series of commands from the terminal (oh, here we go, a long list of crazy complicated…)

This command will create all the files necessary to start a new Ruby on Rails project

Another three word command, and the third of them can be whatever you want to name your project (barring a few protected words that rails protects from being the name of your project, like ‘test’, which by itself would be a bit confusing anyway). You can now change directories into your project, and run an even simpler command from your terminal to be sure that you really have created your own Ruby on Rails project:

This command will launch a local server so that you can visit your Ruby on Rails project as it is currently

Now open your web browser and navigate to http://localhost:3000 and you should see a built in welcome page letting you know that you have successfully built a Ruby on Rails project.

This splash page probably doesn’t do much for you, or really make you feel too excited about what you have learned on its own, as it only shows something that is not even your work. In the navigation pane of whatever text editor or IDE you are using, scroll through all the files and folder that running that rails new my_project command generated for you until you find a folder called config. Open the file called routes.rb and add a line to it so that your file looks like this:

That faded grey line (called a comment) should already be in there, and ignore the blue dot.

Now back to your navigation pane and open up the app folder and then open the controllers folder where you need to add a new file called welcome_controller.rb. Go ahead and open up your new file and add these lines:

These few lines of code will tell your program what ‘view’ file to display.

Now back in your app folder you should navigate to your views folder and within that folder make a new folder called welcome and inside that folder make a file called index.html. This file will contain the HTML that the browser will load on your new page. I am not going to walk through all the options available to you here, but a super basic piece of HTML added to our file will show us that it is in fact our page, so let’s make this addition:

This basic piece of HTML will display the sentence ‘Welcome to My Project!’

Now let’s go back to our terminal and run the command rails server, then navigate in your browser back to http://localhost:3000/ and you should see your sentence appear!

Of course mastering the creation of your own webpage will entail learning a lot about using stylesheets, maybe some JavaScript, creating a lot of different pages through your controllers and, on Ruby on Rails, you will probably need to learn a little Ruby. Before any of that though, you may be wondering how this little page of yours can go from living on your machine to the World Wide Web! There are many hosting options for you to explore to get your little site online, but how about an easy to use, free option?

Integrating your Ruby on Rails project to Heroku is easy and you can upload your project to be hosted online for free (at least while you are starting out with you project). You may have to learn a few Git commands to run from your terminal in order to connect your project to your new Heroku account, but Heroku provides steps to follow from sign up to deployment that should be easy and straightforward to have your Ruby on Rails project go from your local machine to the whole world in minutes.

Hopefully this post makes you excited to explore more about creating your own website on Ruby on Rails and has shown how easy it is to get started for yourself! Ruby on Rails has plenty of online resources and a large online community of developers which both help to easily be able to trouble shoot any problems you may have along the way. While you may not feel comfortable yet with the concept of being a web developer, making your own website is easy, and can be accomplished at a low starting level in just a few minutes. After that, all that is left is to begin the process of learning how to refine your craft on your way to that perfect website for you!