terça-feira, 29 de outubro de 2013

Introduction to Ruby on Rails - In progress

Ruby on Rails
===============
To read about the language Ruby, go to Introduction to Ruby.

Definitions
            Web Application development Framework written in Ruby. Aims to make web develpment easier.
            Principles(philosophy)
                        DRY - "Don't Repeat Yourself"
                        Convention over configuration: If everybody does in a way, it should be a pattern, then for basic operations, just follow the convention.
Install:
            http://railsinstaller.org/
            This tool installs many applications:
                        Ruby 1.9.3 : The language and its compiler.
                        Rails 3.2: The framework Rails
                        Bundler: To manage dependencies(like Maven, Gradle)  http://bundler.io/
                                   Tracks the application code and its rubygems it needs to run.
                                   Specify your dependencies in a Gemfile in your project's root:
                                   automates the intalation and matainance of gems in gemsets.
                                   source 'https://rubygems.org'
                                   gem 'nokogiri'
                                   gem 'rack', '~>1.1'
                                   gem 'rspec', :require => 'spec'
                        Git: To access the github and so on.
                        Sqlite: Simple and local database.  Everything is saved in a file.
                        TinyTDS:  Simple FreeTDS(Tabular Data Stream) for ruby.  Library that can includes a ODBC to access SQL Sever or Sybase.
                                   FreeTDS is very used by UNIX/Linux developers.
                        Suporte do SQL Server
                        DevKit Development Kit for C++ and Ruby.
            Other links     
                        Good to use Sinatra.  Auto web container.  It is like spark or springboot.
                        Another good IDE
                                   http://www.sublimetext.com/2
                        And another famous IDE (SubMine) from jet brains.
                                   http://www.jetbrains.com/ruby/
                        http://rubygems.org/
                                   Tool that goes to a community's gems host for ruby. 
                                   RubyGems is a package management framework for Ruby
                                   A GEM seems to be a kind a plugin or a package.
                                  
                                   To install: ruby setup.rb
                                   After:
                                               gem update --system  //Update to the latest RubyGems version
                                               gem build foo.gemspec //Build your gem
                                               gem push foo-1.0.0.gem //Deploy your gem instantly
                        https://rvm.io/ (Ruby Version Manager)
                                   RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.
                                               Switches between different Rubies and GEM environments
                                               Seems the blunder can be integrated with RVM
                                               http://rvm.io/integration/bundler
                                               http://www.ginzametrics.com/blog/rvm-bundler-in-five-seconds/
            - Steps
                        1 - Installs railsInstallar(in root)
                        2 - Install rubygems
                                   Unzip and call ruby setup.rb
Creating a new application called gestbook
            - rails new gestbook
                        Creates a application and install all the dependencies(gems).
            - cd gestbook
                        Many directories and files are created, the most imprtant for developer is app/, because in this directory we find all files of controller, model, views, helpers.
            - bundle install
            -if there is a error: gem install uglifier
           
            - To run the rails: rails server.
            - Server is running, then, go to http://localhost:3000
                        The result is the following page:



            My small project, guestbook will have this configuration:
                        User -> name, email, webpage, title, aboutme
                        Comment -> String comment, User user. belongsTo feedback
                        Feedback -> title, feedback, User user, hasmany comments


To be continued......

Nenhum comentário:

Postar um comentário