Ruby on rails programming courses. Ruby for beginners: what is interesting about this language and how to learn it effectively

"Hi! What are you doing?" - “Yes, I’ll program one thing in Ruby.” - "It's contagious:-)"
Here is a conversation I had today with a friend. Why Ruby?

Why Learn Ruby

This question concerns those who have been programming in PHP for a long time and successfully. You have mastered one language, which is great, but do not stop there. Many may object that they know the language, are oriented in nyoi and have already learned all the tricks with it. I will name a few reasons to learn Ruby.

  1. Curiosity. For example, it was very interesting for me to work with open classes. This is how to take and inject your method into the system class - in my opinion it's great. Will there be confusion? But how to do it? In general, everything new is interesting.
  2. . Because I've been programming in PHP for a long time, I'm wondering what Ruby can boast of in front of PHP /
  3. Ruby Speed. A twitter is made in Ruby (although it has been abandoned recently). I would like to test its performance in reality.
  4. Problem class. Ruby is good for web applications. Is that so?
  5. Metaprogramming. Perhaps the most important reason.

How to learn Ruby. Academic plan.

This is where my first mistake was that I started learning the framework without knowing the language. Now I understand that this is not necessary. Forgetting about Ruby on Rails for a while, I began to study Ruby itself, since a system task hung in the ticket system for a long time, which was hard to solve in php. I really didn't want to give it root permissions. So the plan is this.

  1. Functions, classes, public classes. Attributes (accessors and mutators).
  2. Working with strings, with arrays. Finding and replacing substrings, etc. Type conversion.
  3. Working with files.
  4. Working with the system environment.
  5. Application design, work with gems (modules).
  6. Working with DB.
  7. Installing Ruby on Rails, .

In this post, I will publish my first Ruby application and invite everyone to the discussion. Point out mistakes, offer best practice, ask questions.

Let's learn Ruby together!

Lesson 1. The first application in Ruby.

The task is this. There is a DNS server on the hosting, and when calling the ruby ​​console utility, you need to add a zone for the domain, as well as a zone entry to the list of zones (domains.list) and change one entry in the database where to register this domain. Database access settings are stored in the php application, specifically in its INI file. After all the steps, you need to restart the DNS server (bind).

Workbench for Ruby

As an IDE, I will use RubyMine from JetBrains. I really liked them. Although it was about phpStorm, the quality is immediately visible. We install ruby ​​through RVM first for all users, then we set it up for root and our user.

Extending Ruby Public Classes

To work with INI files in Ruby, we use the gem inifile. But it has a small problem. In a ZF INI file, you can safely use constants, and the lines look like this:

IncludePaths = APPLICATION_PATH "/../vendors/Doctrine/"

Here from APPLICATION_INI then demolishes the gem parser. Specifically, this line does not fit any pattern:

@rgxp_comment = %r/\A\s*\z|\A\s*[#(@comment)]/ @rgxp_section = %r/\A\s*\[([^\]]+)\] /o @rgxp_param = %r/\A([^#(@param)]+)#(@param)\s*"?([^"]*)"?\z/

Here is the situation for using public classes. Let's replace the IniFile::parse function with our own. I will add all additions to the fucntion.rb file

Class IniFile private # # call-seq # parse # # Parse the ini file contents. # def parse return unless File.file?(@fn) section = nil tmp_value = "" tmp_param = "" fd = (RUBY_VERSION >= "1.9" && @encoding) ? File.open(@fn, "r", :encoding => @encoding) : File.open(@fn, "r") while line = fd.gets line = line.chomp # mutline start # create tmp variables to indicate that a multine has started # and the next lines of the ini file will be checked # against the other mutline rgxps. if line =~ @rgxp_multiline_start then tmp_param = $1.strip tmp_value = $2 + "\n" # the mutline end-delimiter is found # clear the tmp vars and add the param / value pair to the section elsif line =~ @rgxp_multiline_end && tmp_param != "" then section = tmp_value + $1 tmp_value, tmp_param = "", "" # anything else between multiline start and end elsif line =~ @rgxp_multiline_value && tmp_param != "" then tmp_value += $1 + "\n" # ignore blank lines and comment lines elsif line =~ @rgxp_comment then next # this is a section declaration elsif line =~ @rgxp_section then section = @ini[$1.strip] # otherwise we have a parameter elsif line =~ @rgxp_param then begin section[$1.strip] = $2.strip rescue NoMethodError raise Error, "parameter encountered before first section" end elsif line =~ %r/APPLICATION_/ then next else raise Error, "could not parse line "#(line)" end end # while ensure fd.close if defined?fd and fd end end

I'll also extend the String class to allow validation of domains.

Class String def valid_domain_name? domain_name = self.split(".") name = /(?:+)+/.match(domain_name).nil? tld = /(?:(2)|aero|ag|asia|at|be|biz|ca|cc|cn|com|de|edu|eu|fm|gov|gs|jobs|jp|in|info| me|mil|mobi|museum|ms|name|net|nu|nz|org|tc|tw|tv|uk|us|vg|ws)/.match(domain_name).nil? (domain_name.count > 1 and name != false and tld != false) end end

Sources

Well, now I'll show you the actual source.
index.rb

#coding: utf-8 require "mysql2" require "socket" require "inifile" require "./functions.rb" # Hash of server machine addresses hosts = ( :production => "83.168.22.1", :test => "84.22 .11.1" ) util = Util.new(hosts) util.releative_config_path="/site.com/application/config/application.ini" # Check parameters quit if (ARGV.count != 2) domain = ARGV hostname = ARGV. split(".") quit("Invalid domain name") if (not domain.valid_domain_name?) # Search for a company in the database result = Mysql2::Client.new(util.get_db_settings).query("SELECT id FROM `sites` WHERE `hostname` = "#(hostname)"") quit("Company not found") if result.count != 1 # Update its hostname rows = Array.new result.each(|row| rows<< row} company_id = rows["id"] result = Mysql2::Client.new(util.get_db_settings).query("UPDATE `dbname`.`sites` SET `domain` = "#{domain}" WHERE `dao_companies`.`id` =#{company_id};") # Добавление зоны bind_config_path = "/etc/bind" default_zone_file = bind_config_path + "/zones/DEFALT" new_zone_file = bind_config_path + "/zones/#{domain}.zone" zones_list_file = bind_config_path + "/domains.lst" quit("File with default zone does not exists") unless File.exist?(default_zone_file) quit("File with zones list does not exists") unless File.exist?(zones_list_file) zone = IO.read(default_zone_file).gsub("SERIAL",Time.now.strftime("%Y%m%d%S")).gsub("DOMAIN", domain) if not File.exist?(new_zone_file) then File.open(new_zone_file, "w") {|f| f.puts(zone) } else quit("Domain "+domain+" zone already exists!") end # Добавление зоны в список zone = "zone \"#{domain}\" { type master; file \"/etc/bind/zones/#{domain}.zone\"; };" if not IO.read(zones_list_file).include?(domain) then File.open(zones_list_file, "a") {|f| f.puts(zone) } end # Перезапуск сервисов (bind9) system("service bind9 restart") puts "Completed"

gemfile
This file describes the dependencies of the project.

Source:rubygems gem "mysql2", "0.2.6" gem "inifile"

Well, actually included functions.
functions.rb

#coding: utf-8 class String def valid_domain_name? domain_name = self.split(".") name = /(?:+)+/.match(domain_name).nil? tld = /(?:(2)|aero|ag|asia|at|be|biz|ca|cc|cn|com|de|edu|eu|fm|gov|gs|jobs|jp|in|info| me|mil|mobi|museum|ms|name|net|nu|nz|org|tc|tw|tv|uk|us|vg|ws)/.match(domain_name).nil? (domain_name.count > 1 and name != false and tld != false) end end class IniFile private # # call-seq # parse # # Parse the ini file contents. # def parse return unless File.file?(@fn) section = nil tmp_value = "" tmp_param = "" fd = (RUBY_VERSION >= "1.9" && @encoding) ? File.open(@fn, "r", :encoding => @encoding) : File.open(@fn, "r") while line = fd.gets line = line.chomp # mutline start # create tmp variables to indicate that a multine has started # and the next lines of the ini file will be checked # against the other mutline rgxps. if line =~ @rgxp_multiline_start then tmp_param = $1.strip tmp_value = $2 + "\n" # the mutline end-delimiter is found # clear the tmp vars and add the param / value pair to the section elsif line =~ @rgxp_multiline_end && tmp_param != "" then section = tmp_value + $1 tmp_value, tmp_param = "", "" # anything else between multiline start and end elsif line =~ @rgxp_multiline_value && tmp_param != "" then tmp_value += $1 + "\n" # ignore blank lines and comment lines elsif line =~ @rgxp_comment then next # this is a section declaration elsif line =~ @rgxp_section then section = @ini[$1.strip] # otherwise we have a parameter elsif line =~ @rgxp_param then begin section[$1.strip] = $2.strip rescue NoMethodError raise Error, "parameter encountered before first section" end elsif line =~ %r/APPLICATION_/ then next else raise Error, "could not parse line "#(line)" end end # while ensure fd.close if defined? fd and fd end end def quit(message=nil) banner = " === ========================== | DNS Addition tool | ============================ Usage: ruby ​​./index.rb domain.com olddomain.site.com" if not message.nil then banner = message end puts banner exit end class Util attr_accessor:hosts, :releative_config_path, :environment def initialize(hosts =Array.new) self.hosts = hosts end # Get the local IP address def local_ip orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily UDPSocket.open do |s|s.connect "64.233.187.99", 1 s.addr.last end ensure Socket.do_not_reverse_lookup = orig end # Get the environment def get_environment if @ environment.nil? then hosts = self.hosts.invert if(hosts.include?(self.local_ip)) then @environment = hosts else @environment = "development" end else @environment.to_s end end def get_config_path local_username = get_local_username "/home/" +local_username+"/sandbox"+self.releative_config_path end # Returns the username if the utility is run via rvmsudo or directly def get_local_username if ENV["SUDO_USER"].nil? quit("Util should be run over rmvsudo, \r\nexample: rvmsudo ruby ​​./index.rb domain.ru some.subdomain.ru") else ENV["SUDO_USER"] end end def get_db_settings config = IniFile::load( self.get_config_path) section_name = self.get_environment.to_s + " : bootstrap" quit("No suitable section in config file") unless config.has_section?(section_name) dsn = config.to_h["resources.doctrinedata.connections.default. dsn"] # Parse dsn dsn.sub!("mysql://", "") arr = dsn.split("@") dbconfig = ( :username => arr.split(":"), :password = > arr.split(":"), :host => arr.split("/"), :database => arr.split("/") ) end end

But what about PHP?

This post is not about quitting PHP and learning ruby. PHP is the most popular web programming language, thousands of interesting things and algorithms are implemented on it, incl. even neural networks. And I love him) Over the years, you can say that I became related to him, despite all his shortcomings. But this does not mean that you should not learn something new for yourself.

Recently I have been asked the question of what books to learn Ruby from. I'm reading this one right now.

This book is the official guide to the dynamic programming language Ruby. The team of authors is truly stellar: David Flanagan is a well-known specialist in the field of programming, author of a number of best-selling books on JavaScript and Java; Yukihiro "Matz" Matsumoto is the creator and lead developer of Ruby.
The book provides a detailed description of all aspects of the language: the lexical and syntactic structure of Ruby, varieties of data and elementary expressions, definitions of methods, classes and modules. In addition, the book contains information about the Ruby platform APIs.

The publication will be of interest to experienced programmers who are getting acquainted with the new Ruby language, as well as to those who are already programming in Ruby and want to achieve a higher level of understanding and workmanship. You can find a book on ozone or a biblio-globe.

I look forward to your comments on the code and any interesting ideas!)

Thank you!

If this article helped you, or if you want to support my research and blog, here's the best way to do so:

This is the first of a series of articles in which I will talk about the features of Ruby and Ruby on Rails and share tips on how to get started in learning Ruby, where to find answers to questions, how to get the right experience, and how you can stand out from other candidates. I will be glad if my advice will help someone decide on a specialization and choose Ruby for learning and working.

Key Features and Differences of Ruby

I often hear the question: is it worth learning Ruby? As a rule, the question is based on doubts: how easy it is to find a job with this specialization, whether there will be interesting projects, and so on and so forth. Ruby is a modern, constantly evolving programming language, there are a lot of applications for it. Surely you have heard about Chef, Vagrant, Homebrew, but most often we all hear about Rails. Here is a post with a commentary by the author of the framework about why you should learn Rails.

Of course, everyone decides for himself which tool to use. And there is no point in endlessly arguing about why one technology is better than another. I chose Ruby because it is an incredibly expressive and flexible language that allows you to solve the same problem in many ways.

Ruby is an interpreted, fully object-oriented programming language with strong dynamic typing. It combines a Perl-like syntax with an object-oriented approach. Also, some features are borrowed from the programming languages ​​Python, Lisp, Dylan and CLU. The cross-platform implementation of the Ruby language interpreter is distributed under the terms of open source software. Code written in Ruby can be understood even by a person who does not understand programming. Projects such as Redmine, Twitter, Shopify, Basecamp, GitHub, Kickstarter, Airbnb and others have been created on RoR.

With the rise of Node.js, the popularity of Ruby on Rails has waned somewhat, but tech startups often use RoR due to the ease of prototyping. Ruby is the 11th most popular language in the TIOBE index.

Benefits of Ruby

  • Numerous and friendly community.
  • A rather high barrier to entry, which means that a Ruby developer is likely to have experience in at least one other programming language.
  • You only use the libraries and modules you need.
  • There are a large number of useful libraries that are ready to use (Ruby Gems).
  • There is a lot of information on Ruby on the Internet, in a structured and sifted form.
  • In the context of the discussion of Ruby, it is impossible not to mention the most popular Ruby on Rails framework.

Now let's talk about some of the benefits of Ruby in more detail.

Development speed

One of the advantages of Ruby and the RoR framework is development speed. Personal experience and the experience of colleagues shows that solving problems on Rails is one and a half times faster compared to other similar frameworks. Ruby is very simple as a tool, and there are a huge number of ready-made solutions for various kinds of tasks.

Regular data caching tools

When developing a large-scale project, one of the most important points is caching. Ruby on Rails comes standard with native data caching tools. That is, you will immediately have tools for caching data on the project, and you can easily cache individual blocks of code or even entire pages.

First tests, then code

Often in the process of developing large projects, the question of testing arises, and it is not uncommon when there are no additional funds for a separate team of testers. Rails has a solution to this problem as well. If you compare RoR with other frameworks in the context of application testing, then you will find a lot of ready-made solutions for any kind of tests, be it integration or unit tests. All these libraries work out of the box. Ideally, in a Ruby on Rails project, code is not written until tests are written for it. RoR ideology involves the initial use of BDD (Behavior Driven Development) or TDD (Test Driven Development) methods.

Generally accepted development process standards for Ruby developers

Speaking of the benefits of Ruby, I can't help but mention the ruby ​​community again. It is constantly growing, developing and always ready to help. There is always someone who will tell you how best to solve the problem, share experience in any matter.

Another very important point is that the Ruby community has had standards for the development process for many years, some rules/community agreements that govern development, which greatly simplifies the work. Due to these standards, each project is very structured, respectively, a new developer in the team will quickly get up to speed and be able to be useful from the first days of work. And even more: if the project was started by one team and finished by another, this is also not a problem at all. Since the development is carried out according to the already mentioned rules and community agreements, the new team will quickly and easily delve into the project and successfully complete it without much loss of time.

Also, Ruby on rails has a large number of different ready-made solutions in the public domain. Most of the solutions have already been implemented by someone before you, as well as tested by the community, which reduces the need to develop from scratch. These can be authentication, authorization, commenting systems, payment systems, mailing lists, and so on.

Ready-made solutions for project multilingualism

Rails comes with very powerful tools for project localization out of the box. It is possible both to provide support for several languages ​​initially, and to implement it later. The project contains special files for translating terms, tools for displaying templates in different languages, and much more.

High level of data protection

Now, articles about hacking various resources are often published on the network. The developers of the Ruby on Rails framework took the issue of data protection very seriously. RoR initially encrypts passwords, credit card data and other personal user data, SQL injections and XSS attacks are also excluded. All input parameters are escaped by default.

Learning Ruby

Now let's talk about exactly how you can master Ruby.

Theory

You should start, of course, with literature. I recommend these sources:

  • Ruby in 20 minutes is a good resource for complete beginners. It allows you to get acquainted with the basic constructions of the language in less than half an hour and start writing your own small programs.
  • Codecademy is a platform with online courses in many areas, including pure Ruby and Rails. Here, the learning process is built quite interestingly, theoretical material is given and immediately a practical task in order to consolidate it. Final tasks are paid, but without them you can get the necessary skills.
  • Ruby and Rails Resources - A collection of links to various sites and books dedicated to learning Ruby and Rails.
  • Separately, I can recommend the book Flanagan D., Matsumoto Y. "The Ruby Programming Language". It is considered one of the best, its author is the creator of the Ruby language himself.
  • Google :)

Here are a couple of resources to get you started:

  • w3schools.com/sql - Read, try and test your knowledge of SQL here.
  • quizful.net/test - Here you can find questions that are often asked in interviews.

English

I believe that it makes no sense to dwell on this point in detail, since this is the topic of a separate article. English is very important and this is a well known fact. I would like to briefly mention two of the most important points.

Firstly, English is the main language of the international community, so most of the useful literature will also be in English, many news, reports and important articles will also appear first in English. If you want to know the answer to any question, it is very likely that you will be able to find it in English first of all.

Secondly, the better your knowledge of English, the more likely you are to find a job. Most of the clients are foreign, therefore, knowledge of English is important for productive communication, a clear understanding of the technical requirements and good contact with the client.

Practice

After exploring a few resources, it's time to move on to the more important part, which is practice. There are a lot of examples of tasks with an online store or a simple blog on the web (here is one of them), especially if we talk about Rails. In the course of completing tasks that are already a little close to real, you will definitely encounter some problems and then move on to training one of the most important qualities - the ability to google. Unfortunately, I was unable to find any tutorial or courses dedicated to this skill, but it definitely plays a very important role in everyday work.

Courses

After reading the theory and writing several “pet projects”, you can, of course, try to go to interviews, but it often happens that this knowledge is not enough. This is due to the large influx of candidates, and given the competition, everyone tries to stand out and prepare as best as possible.

Another important point in training, which can be an advantage in your favor when looking for a job, is programming courses. Unless, of course, you have a mentor who is willing to spend a certain amount of time coming up with assignments and reviewing them.

I must say right away that in no case do I recommend going to courses without already having some kind of knowledge base. I see courses as a great way to consolidate the knowledge gained in the process of self-study. And now I’m not trying to advertise any particular school, but I’ll explain exactly what benefits can be derived from this:

Most likely there you will learn something you didn't know before. The courses have a fairly large amount of material that is presented in a structured form, which allows you to better assimilate the material.

During the course you will have mentor, which will review the solution of your tasks and point out weaknesses and errors.

Motivation. This is primarily for those who need help with self-discipline. Sometimes it is quite difficult to force yourself to do something, no matter what prospects loomed on the horizon. When attending courses, you will have a clear schedule to follow and assignments to complete or you will be expelled. Financial motivation also plays a role here, in the case of paid courses. After all, when you give your hard-earned money, you already have a completely different attitude to the matter, and thoughts of just skipping arise much less often.

Another advantage - certificate. It is clear that in the end you will be assessed by knowledge, and not by the presence of pieces of paper in your resume. But nevertheless, it will be a plus, especially if there is a candidate with a similar level of knowledge, but without their documentary evidence.

Plus one project on GitHub into your piggy bank. If you are a novice developer, then most likely the project written in the courses will be more interesting in terms of technology than those that were written earlier.

And the most important thing - employment. Speaking of courses, I do not mean only those for which you need to pay money. Often, companies themselves recruit for training, so that later they can hire the best. These can be internal courses or internships/internships. This option is the best, since you do not have to pay for anything, you get experience and all the above pluses, and in addition - a real employment prospect. Getting to them is more difficult, but the prospects are more significant.

Total

Ruby is a language that allows you to work without a lot of the inconvenience and ceremony that comes with strongly typed languages. Ruby is easy to get started with, especially if you already have development experience in other programming languages ​​and can quickly prototype with Ruby on Rails. In Japan, where it came from, Ruby was used to make games. Ruby is concise and reads like English, making the code easy to understand for beginners.

As for learning Ruby, I want to reiterate: you need to start small. Read a few books, do a few tasks on your own, and then, if you feel the need to gain more knowledge and experience or additional motivation, you can go to courses already having a certain amount of knowledge gained on your own.

Ideally, these are courses from a company that, at the end, will make you an offer if you perform well. An alternative option is paid courses that will help you consolidate your knowledge, add another project to your resume and gain experience, which is most important at the start. But do not expect that after completing paid courses, you will easily pass the interview by showing a certificate. In any case, knowledge will be evaluated.

At the same time, having enough motivation, patience, abilities and experience with other programming languages, you can easily master Ruby on your own, because there is a lot of useful and well-structured information on the Internet. Also, thanks to the open and numerous Ruby community, you can easily find answers online to many possible questions that, with a high degree of probability, someone has already asked before you.

Good luck with your study! And in the next article we will talk about the code.

Subscribe to our Telegram channel for juniors so as not to miss interesting vacancies, internships, courses, articles.

Good day!

Foreword

Once I wanted to get to know Rails better, but did not know where to start until this article caught my eye. Further you will see the translation, mixed with my own experience and lexical and phraseological turns peculiar to me. So let's go.

Introduction

I have a lot of experience with PHP behind my back, but now I'm working as a Rails developer. A huge challenge for most people who are trying to learn something new is the learning process itself. When you own any language or framework and know it inside and out, switching to something new does not seem necessary.

However, learning Ruby on Rails is fairly straightforward. It's an incredibly powerful framework that has a huge community pushing it forward. So our question is: what is the best way to learn Rails? Here is the lesson plan.

This article is a complete lesson plan to get familiar with Rails and get started in no time. All you need to do is follow the steps below, which are listed in order.

Item 1: Working with Exercises in Try Ruby

You might think that learning Ruby is the most important step here, but it's not. Some of those who start learning Ruby in detail stop learning and just stay with their current language and framework. Do not do that!. Don't be afraid to learn this language (or any other). Ruby is a fun, great and easy to learn language. Plus, do not forget that you do not have to study it 100%. You just need to know the basics.

The most recommended tool for diving into Ruby syntax is the TryRuby site. It is an interactive environment that allows you to try the syntax in action. If you type help, you'll be invited to a fifteen-minute tutorial that will teach you the basics. Do not forget that the guide has two chapters, which you can read by typing help 2.

If you work hard on these tasks for some time, then you will have a good knowledge base. All I did first was study these two manuals. The rest I learned in the process of developing sites on Rails, as well as through googling and exercises with IRB.

Step 2: Installing Ruby and Ruby on Rails

If you want to learn Rails, then you will no doubt need to install it on your computer. Here are a few solutions based on what OS you have. If you have a Mac or Linux-based computer, then I recommend that you use RVM. This is a great tool for installing Ruby. In fact, here are the installation instructions. If you have Windows, then you will have to use RubyInstaller.

The next step is to install Rails itself. To do this, you need to install RubyGems. If you are using RVM, then congratulations - you already have RubyGems installed. If you have Windows, then I advise you to proceed here. To install Rails, you need to use the command gem install rails and, then, it's done!

Item 3: Check out Jeffrey Way's Introduction to Rails


In this 40 minute screencast, Jeffrie Way walks you through what you need to know in order to use Rails. It contains a lot of useful information, including topics such as:

  • Models and generators
  • Test-driven development (TDD)
  • ActiveRecord
  • RSpec and Capybara
  • Partials
and much more…

Item 4: Learn the Rails For Zombies Course

I've always thought that learning by example is the best way to learn a language or framework. A free and incredibly powerful course that you should definitely check out is Rails For Zombies by the guys at EnvyLabs. This course is interactive, which means that after watching each video, you will work on useful and interesting exercises.

Until now, I have been telling you about interactive and free tools. Freebie time is over! You should now purchase a book called Agile Web Development with Rails. It aims to teach you how to use Rails by building a website from scratch. It goes through the basics like controllers, models, scaffolding, functional testing, and a bit of AJAX. Get at least the latest edition.

Item 6: Build a Simple Blog

I know this sounds pretty boring (at least to me), but it's a great example that gets used everywhere because it's pretty easy and quick to write. By following this path, you will help consolidate your knowledge and skills. But I suggest that you do not copy-paste (you will not achieve anything with this, except perhaps 10 minutes of wasting electricity), but try to write it gradually, from memory, sometimes only peeping into a book to see how this or that method works.

Item 7: Add New Features to Your Blog

Fabulous! You still built your own blog. But still, it does not have full-fledged functionality, but only the basic functions inherent in each blog are presented. Okay, let's work a little bit and add an authentication system.

In fact, I don't want to force you to do anything difficult right now, because you have already worked hard. As an authentication system, you can use some ready-made gem (Omniauth, for example). At the same time, you will understand the implementation of gems in your project.

I also recommend watching this screencast by Ryan Bates, which describes how to create a simple authentication system from scratch. After the implementation of the system, you should add the ability to delete / edit posts, if you have not already done so. If the task has already been completed, then it's time to move on to the next item.

Item 8: create something of your own

At this stage, it's time for you to get more creative and think about creating some kind of service (for example, photo hosting). Don't stop at the design of your second website. Take something ready. For example,

I have long wanted to learn Ruby on Rails at some basic level. No specific purpose. Rather, just for myself, in order to better understand what is so special about it (unlike 100,500 other technologies and frameworks), which allows you to quickly create and scale quite loaded Internet projects. A secondary reason was the desire to try new approaches to learning. When I was studying to be a programmer, we only had books and forums where you can ask for advice. Now there are interactive textbooks and online programming schools, a huge number of screencasts (almost a dream: to watch how gurus code), knowledge bases like stackoverflow.com and tons of source code on GitHub, where you can spend hours studying the source codes of real pros. I decided to dedicate the next few nights (and there is no time during the day) to trying new ways of learning in action.

night one

It would be strange to start learning Ruby on Rails without at least a minimum knowledge of Ruby directly. I've taken on the ruby-lang.org interactive guide before. But as I passed it, I immediately forgot everything. Its creators promise that it will take fifteen minutes to walk through and master the Ruby syntax. It took me thirty. True, with constant distraction on Twitter. The process looks something like this. They tell you: “Arrays in Ruby are declared like this, and data is retrieved from arrays like this. Now let's try to make an array and extract N elements from it. And we'll check." You read how everything is arranged, and immediately try it. Ruby you, of course, will not learn. It is better to think of it as a super-express course that works.

Still, Ruby itself is very far from the Ruby on Rails framework. I wanted to master the rails. From our article about online education, I definitely remembered the sensational Zombie for Rails railsforzombies.org course. It's just like Try Ruby, an interactive tutorial that starts you off the bat to teach you how to prepare rail applications. First, they give you a mini-lecture (in English, but everything is very clear - turn on the subtitles) about the file structure of a rail application, the CRUD approach for working with data, explain how the MVC model is implemented in rails, and so on. After each video, you are offered to complete assignments to consolidate the material. Everything seems simple and understandable, the course flies by unnoticed in an hour or two (it is small). But! Did I feel after the course that I could write a rail app? Unfortunately no!

Night two

One of the reasons why after Rails for Zombies there is some basic knowledge, but no confidence, is the virtual environment in which the training takes place. On the one hand, it reduces the entry threshold to the limit: you don't have to worry about the environment. On the other hand, you don’t create anything real along the way - no “Hello World” for you at the end. And most importantly, from which side to approach its creation, it is not clear. From that moment on, I wanted to try Ruby on Rails in action, actually installing it on the system (before that, I didn’t even have to try), and create a simple application from scratch.

I don’t remember how, but quite by accident I came across a very successful course of screencasts in Russian rails.hasbrains.org. Thanks to the author for a competent presentation: he methodically explains the principles of the rail application in detail, immersing you in all the necessary subtleties along the way. In short, the entire second night of the experiment, I watched the first half of over thirty episodes of these screencasts.

The picture finally stuck in my head, how the application is generated, how to work with the rail console, how to create models and migrations, how to update models and how to validate data in them, RESTful controllers, and so on. Watching each of the episodes, I immediately tried everything in action, building a fully working rail application. It became clear how the rails are arranged in principle.

Night three

On the third night, the last episodes of screencasts remained, which I managed to watch in one sitting: working with rails no longer seemed so wild. At this point, someone told me that the Rails for Zombies course has a sensible and much deeper continuation. True, the course is already paid and is hosted within the framework of the Code School www.codeschool.com programming school. Paying 25 bucks to get access to all the courses of the school was not a pity. This is the cost per month, so if you don't like it, don't forget to cancel your subscription.

The Rails for Zombies 2 course was really successful. True, a lot was a repetition of what I saw in the screencasts - but it was even kind of nice. Five levels and five blocks of exercises that you do right in the interactive console. By this point, the rails already seemed logical, understandable and usable.

In Code School, you can program directly in the browser by completing course assignments

What's next?

Have I learned to do complex projects? No. But I definitely realized the approaches used in the rails, and understood their convenience. I learned how to quickly create simple applications and increase its functionality in a super-short time using gems written by the community. I caught the courage and continue to study with pleasure the best practices in the Code School programs (now I'm watching the course on unit tests). And I am damn pleased that learning technology has become so easy.