Ruby on Rails: My initial exploration

Ruby on Rails: My initial explorationDaniel S.

TomaBlockedUnblockFollowFollowingJan 21Just three months ago, I had never seen Ruby code.

Then I was accepted to a bootcamp, and was given labs to complete…in Ruby.

I started with the traditional ‘Hello World’, and took it from there.

Now, two weeks into that bootcamp, my cohort is one week from starting our second module: Ruby on Rails.

Guy walking on rails, although *HE* might actually know where he’s goingSo, like any curious, inquisitive kid might do, I decided to look ahead to dip my toe into the ocean that is Rails.

But I knew that I couldn’t rush to type ‘install Rails’ at the prompt, becauseI’d already experienced configuration issues with Ruby alone, so maybe more issues would arise by installing RailsIf it went smoothly, that would just be too easy, and nothing is that easyAnd what the heck is Rails, anyway???So, rather than dive in, I opted for the toe-dip or, in the common parlance, baby steps…At this point, all I knew of Rails was that our bootcamp cohort is going to begin to learn about it in a week.

Ok, that’s not entirely true.

After some rudimentary research, I learned a few things, and I started my research at what appears to be an important website:Ruby on RailsA web-application framework that includes everything needed to create database-backed web applications according to the…rubyonrails.

orgI was overwhelmed by the amount of documentation, so I made sure to remember one particular point:Ruby on Rails (aka “Rails”) is a web development framework written in the Ruby programming languageNow, filtering that down into exactly what comprises Rails is like going down the rabbit hole in ‘Alice in Wonderland’, but I’m not there yet.

At least, not for another week.

However, one suggestion can immediately be extracted from that “definition”:— — Learn Ruby before digging into Rails.

Seems reasonable, as Rails is built on Ruby, but this begs the question “How much Ruby should one know?” With my cohort, it’s two weeks’ worth, but we move quickly, so those two weeks might be two months for someone else.

I guess it just … depends.

So, why do I like the idea (soon-to-be reality) of Ruby on Rails?It’s free.

Ruby on Rails and most of its libraries are open-source software, so you can install them without using a credit card (Definitely a + in my book)Emphasizes “Convention over Configuration philosophy.

The programmer does not need to spend a lot of time configuring files in order to get setup.

Rails comes with a set of conventions which help speed up development.

The common conventions also make it easier for developers to move between different Rails projectsRapid Application Development.

Rails framework has the flexibility to quickly accommodate changes in the development process.

The process of programming can be faster than with other languages/frameworks, partly because of the object-oriented nature of Ruby and the vast collection of open source code available within the Rails community.

But I’m not here to sell Ruby for Rails.

After all, I’ve never even used it.

However, I am here to brag about installing Ruby for Rails, and I used this page to do it -> https://gorails.

com/setup/osx/10.

13-high-sierraIt’s worth noting that installation instructions are provided for six different versions of the Mac OS X, ranging from 10.

9 through 10.

14 inclusive.

I currently use 10.

13 (High Sierra), so I used the instructions from that page.

Furthermore, this site — https://railsapps.

github.

io/installrubyonrails-mac.

html — states that, for Mac users, the OS should be at least 10.

13.

I don’t have a Windows machine, but the documentation for installing Rails on a Windows machine seems to be quite sparse relative to that for Mac users.

Another page for installing Rails, but I barely looked at this one.

http://installrails.

com/Referring to the instructions, Homebrew and Ruby (2.

3.

3) were already installed, and Git was already configured.

Thus, I went straight to the Rails step, which installs the most current, stable release.

I did this via Terminal in my /Users/danieltoma directory.

gem install railsYou could also append a specific version to this command, which you might do if you wanted to install an older version of Rails (perhaps you’d need an older version to play well with other older components).

So, rails-5.

2.

2 is apparently the most current, stable release.

Also installed with rails was railties-5.

2.

2.

As of now, all I know about railties is that they work with Rails, and are necessary.

rails -v…yields Rails 5.

2.

2.

Awesome!Then, the instructions talk about setting up a database, and there are three that are specifically mentioned:Sqlite3MySQLPostgresqlThe author recommends using Postgresql, although my current cohort has already used Sqlite3, which also happens to ship with Rails.

I believe that any of these databases would suffice for me, particularly as a Rails beginner, so I’ll postpone installing another database.

For now, it’s Sqlite3.

Now it was time to create a Rails application, but I hesitated a bit, wondering if clicking ‘Enter’ would yield unpredictable results…Ok, it wasn’t as bad as my laptop catching fire, but when I typed the following and hit ‘Enter’, I did receive an unexpected message.

rails new fooAnd that message was Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory firstUm.

yeah.

I immediately Googled that lovely message, and found someone on Stack Overflow who had experienced the same, and had taken the following steps, which had apparently eliminated the problem.

cd bin (I was now in /Users/danieltoma/bin)rm -rf railsThese two steps apparently eliminated the error for me, too, because when I executed rails new foo, I watched as many files and gems were created right before my eyes.

rails new foo –> created a folder in /Users/danieltoma named 'foo'And then I gazed upon the contents of the ‘foo’ directory, the directory containing my Rails app.

Then I did this…Finally, the instructions say that I can see my app at http://localhost:3000 , and when I go to that address I see the following.

I went through all of that for this???.Absolutely!!.And it was worth it, too!!In closingI just touched the tip — of the tip — of the iceberg that is Rails.

It was actually quite fun just to see if I could do enough to see something in the browser to indicate that I had actually done something that could lead to a viable app.

As the song goes, the best is yet to come….. More details

Leave a Reply