Matsumoto in the mid 90s in Japan - “I wanted a scripting language that was more powerful than Perl, more object-orientated than Python. That’s why I decided to design my own language” • Everything in Ruby is an Object What is Ruby? Monday, 16 April 12
instructions to a machine • It is a collection of syntax and semantics like any other language. However these must be strictly obeyed or a computer will not understand • A scripting language is one that supports the writing of scripts, typically to automate the execution of tasks • Scripts can be written and executed on-the- y without explicit compilation into machine code before hand What is a programming language? Monday, 16 April 12
They think, "By doing this, the machine will run faster. By doing this, the machine will run more e ectively. By doing this, the machine will something something something." • They are focusing on machines. But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves. Why is Ruby di erent? Philosophy Monday, 16 April 12
It’s written in Ruby (a programming language) • It’s open source (MIT License) and free to use • It was written by DHH of 37signals and released to the public in 2004 Ruby on Rails? Monday, 16 April 12
essentially a collection of tools, techniques and patterns wrapped up in a convenient package • Because 90% of the time you need to do the same things as everyone else • Frameworks can even be made of other frameworks (woah, meta) What is a Framework? Monday, 16 April 12
useful classes and methods that you might need • A framework generally provides a collection of core code that gives you a structure to write your own software • Libraries are usually lower level and do very speci c things, frameworks will generally consume many libraries and glue them all together cohesively • Once you adopt a framework it’s di cult to change, however libraries that are used in your application can usually be swapped easy enough Monday, 16 April 12
tools to build an application • A CMS is an application specialised to serve and manage content, usually static sites or a blog • Most CMS are built on top of a framework themselves • @rumblelabs we don’t generally use CMS as they are too specialized and end up getting in the way of experimentation and innovation. Monday, 16 April 12
external libraries that we want to use in our applications, called Rubygems http://rubygems.org • A gem is a library (but can be a framework too, Rails is released as a Gem) • They provide useful reusable code for speci c tasks that we can just include for free in our applications • Always look for a library that does something you’re trying to do, don’t reinvent the wheel Monday, 16 April 12
let you use and switch between multiple versions of Ruby on your machine. http://beginrescueend.com/ • It is to Ruby what Rubygems is to gems • It’s great for working with old Rails applications / Ruby code or for working in teams Monday, 16 April 12
• It allows the easy speci cation of what gems to use in a Rails project and even what version • It lets you keep multiple machines, you, your coworker’s and your server all with the same versions of external code. • It’s best used with RVM on your machine Monday, 16 April 12
them • All optimised for human qualities of happiness, reusability, productivity and collaboration • Good communities behind their development and usage Monday, 16 April 12
Ruby and Rails for user interface development • CSS Tools like: SASS, Compass, Bourbon • JavaScript Tools like: Co eeScript • Rails 3 Asset Pipeline, keep your assets more organised and automatically compile and minify your CSS and JS • No shortage of work for Ruby developers and designers these days Monday, 16 April 12
version we want rvm use 1.9.3@rails-3-2 --create gem install rails ## Generating a new App rails new blog ## Add a custom .rvmrc file to manage this project’s ruby version cd blog echo "rvm 1.9.3@rails-3-2" >> .rvmrc ## Setup a new git repository git init git add . git commit -m “First commit” Monday, 16 April 12
database.yml if you want to use MySQL etc.) rake db:create ## Startup the rails development server rails s ## Open a browser open http://localhost:3000/posts ## Generating a scaffold model controller and views rails g scaffold Post title:string content:text published_at:datetime ## Migrate your database rake db:migrate Monday, 16 April 12
our Gemfile gem 'bootstrap-sass' gem 'simple_form' ## Add to our app/assets/posts.css.scss @import "bootstrap"; ## Get this custom simple_form configuration to make it play nice with bootstrap curl https://raw.github.com/rafaelfranca/simple_form-bootstrap/master/config/ initializers/simple_form.rb > config/initializers/simple_form.rb Monday, 16 April 12
•Using the Asset Pipeline •Using Twitter Bootstrap •Deployment to Heroku •Building an admin panel •Commenting on a post? •Post has_many comments •Push to github Monday, 16 April 12