Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby Day @ Ramallah

Ruby Day @ Ramallah

A quick introduction about Rails. Using scaffold to generate an application. Most of the audience have never heard about Ruby/Rails.

Amr Tamimi

April 27, 2013
Tweet

More Decks by Amr Tamimi

Other Decks in Programming

Transcript

  1. Application from A to Z A.K.A. From Zero to Deploy

    Rails makes you develop your web application with a smile on the face, I promise.
  2. Fact This is not Ruby! Her name is Rania and

    known as Ruby! en.wikipedia.org/wiki/Ruby_(Egyptian_singer)
  3. Amr and Ruby A True Love Story Since 2007... Six

    years! Yes! the longest relationship I've ever had!
  4. "Ruby on Rails" or just "Rails"? Ruby on Rails became

    Rails with version 3.0 after partially merging some components from Merb framework.
  5. rails new ./demoapp -T Also, theres lots of options to

    pass. Type rails to see the options and the defaults. I skip installing Test Units. It will run bundle install after. Rails New
  6. bundle || bundle install || bundle update Bundler is a

    Ruby dependency manager. Rails uses Bundler mainly to manage its dependencies and gems. Bundler, ah?
  7. Rails adopts MVC architecture • Model ◦ Database and logic

    • View ◦ Layout, views, what end-user sees. • Controller ◦ The layer between the models and the views Read more: net.tutsplus.com/tutorials/ruby/why-rails |-- Gemfile |-- Gemfile.lock |-- app | |-- assets | |-- controllers | |-- helpers | |-- mailers | |-- models | `-- views |-- config |-- config.ru |-- db |-- doc |-- lib |-- log |-- public |-- script |-- tmp `-- vendor Rails Application Layout
  8. rails generate The main Rails generators (or the handy ones):

    rails g scaffold rails g model rails g controller rails g migration Rails Generate
  9. rails g scaffold rails generate scaffold MODEL_NAME [field[:type][:index] (...)] [options]

    Example rails generate scaffold post title:string body:text Rails Generate Scaffold
  10. Let's Run the Server No posts table? No problem! run:

    rake db:migrate Notice, we use sqlite3 database. The database will be created automatically. For other databases run the command below before rake db:migrate. rake db:create
  11. Let's Deploy heroku.com Using Just some simple commands: • Add

    it to a Git repository ◦ git init ◦ git add . ◦ git commit -m "a message - lets deploy" • Install Heroku Toolbelt: toolbelt.heroku.com • heroku create • git push heroku master • heroku run db:migrate (use pg in prooduction) • heroku open