Bitmaker Labs – Day 11

For the start of our third week here, we dove right into Rails today. It started off with theory and general knowledge, then towards the end we started working on a Rails app. Not a single person in class knew what was going on, that’s how confused we were by the end of the lecture. The instructors told us that that’s normal, and is to be expected. We’ll be doing Rails for the next two weeks, so we’ll have plenty of time to get accustomed to it.

My first impressions of working with Rails is that it’s weird to see HTML and Ruby code working together. Here’s an example of it:

<h1>Pictures (<%= @pictures.length %>)</h1>
<%= link_to "New Picture", "/pictures/new" %>

<% @pictures.each do |picture| %>
	<p><%= picture[:title]%>, <%= picture[:artist]%></p>
	<%= link_to image_tag(picture.url), "/pictures/#{picture.id}" %>
	<% end %>

Once you get past the initial “Hmm, this is interesting”, it’s actually kinda cool to see them work hand in hand. The above code basically does this:

  1. Prints “Pictures” and the number of images it has.
  2. Goes over every image in pictures, and prints it with an <img> tag, whilst also linking it in an <a> tag to see the picture by itself if you clicked it.

I’m still a bit overwhelmed trying to understand the MVC, which is fundamental to working with Ruby on Rails(RoR), or any other web framework. I’ll be spending the rest of the night going over the tutorial assignment they gave us, and trying to understand the MVC better. The tutorial assignment is a guide to creating a copy of Imgur using RoR, which is exciting.

 

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*