TeamStation AI System Report LATAM IT Salaries 2024
Intro to Rails Give Camp Atlanta
1. Intro to Ruby on Rails Jason Noble http://jasonnoble.org Alan Hecht http://alanhecht.me
2. Slides are available http://slideshare.net/jasonjnoble/ Intro to Rails Give Camp Atlanta Finished code is also available https://github.com/jasonnoble/givecampatl-rails-demo
3.
4. History Initial Release July 2004 Written by David Heinemeier Hansson Rails 3.0 released August 29, 2010
5. Technical Overview Model-View-Controller (MVC) architecture Includes scaffolding to automatically construct the models and views needed for a basic site Includes WEBrick, a simple Ruby web server Includes Prototype and Script.aculo.us JavaScript libraries for Ajax RESTful web services used instead of SOAP Handles HTML and XML output out of the box
6. Framework Structure ActiveRecord – Object relational mapping system for database access ActiveResource -- Web Services ActionPack ActiveSupport ActionMailer Lots of plugins available
7. Philosophy Convention over Configuration Decreases decisions that developers need to make By doing things the “standard” way it just works Don’t Repeat yourself (DRY) Every piece of code has a single, unambiguous authoritative representation within a system Modifying any single element does not change other logically-unrelated elements Use methods and subroutines to abstract out pieces of code called in multiple places
8. Installing Install Ruby and RubyGems Gems are a Ruby package format gem install rails Rails works with SQLite out of the box MySQL, PostgreSQL, Oracle, MS SQL gems available
9. Installing Rails Windows http://pragmaticstudio.com/blog/2010/9/23/install-rails-ruby-windows OS X http://pragmaticstudio.com/blog/2010/9/23/install-rails-ruby-mac Linux Most of http://pragmaticstudio.com/blog/2010/9/23/install-rails-ruby-mac will work
10. Let’s build a shopping cart rails new demo_app vi demo_app/.rvmrc rvm –create use 1.9.2@rails3 cd demo_app rails server http://localhost:3000 gitinit . git add . git commit –m ‘Initial rails app’
11. Push App to Heroku vi Gemfile Add “gem heroku” line bundle install heroku create git push –u heroku master heroku open
14. Modifying the view app/views/products/_form.html.erb Views are dynamically rendered, so reloading in your browser will show your updates
15. Seeding your DB with data db/seeds.rb Executes Ruby code to pre-populate your database Good way to start with sample data rake db:seed Runs the ruby code
24. Store Front rails generate controller store index http://localhost:3000/store/index gitrm public/index.html config/routes.rb http://localhost:3000/
25. Store Controller Modify store controller to pull products from the database app/controllers/store_controller.rb
43. Further Reading Agile Web Development with Rails http://pragprog.com/titles/rails4/agile-web-development-with-rails http://rubyonrails.org http://railsforzombies.org/ http://tryruby.org/ http://rubykoans.com/
Notas del editor
heroku create _NAME_ will create an app called _NAME_, i.e. http://_NAME_.heroku.com
Modifying the specified line to include the :precision and :scale arguments.rake db:migrate executes this code to create the products tableThe scaffolding will now be available at http://localhost:3000/products
When you go to /products and click New ProductWhen you submit a product that fails validation, rails automatically generates the error page shown