basic rails projects
play

Basic Rails Projects Professor Larry Heimann Application Design & - PowerPoint PPT Presentation

Basic Rails Projects Professor Larry Heimann Application Design & Development Information Systems Program Why Ruby on Rails? Ruby on Rails is astounding. Using it is like watching a kung-fu movie, where a dozen bad-ass frameworks


  1. Basic Rails Projects Professor Larry Heimann Application Design & Development Information Systems Program

  2. Why Ruby on Rails? “Ruby on Rails is astounding. Using it is like watching a kung-fu movie, where a dozen bad-ass frameworks prepare to beat up on the little newcomer only to be handed their asses in a variety of imaginative ways.” — Nathan Torkington O'Reilly Program Chair for OSCON

  3. Automated tasks • rails new • rails generate • rails server • rails db:create • rails db:migrate • rails test:models

  4. Model basics • ActiveRecord does the heavy lifting • Basic relationships and validations • Other methods can be added Key Idea : Models hold all the data & business logic

  5. History of Active Record • Did not originate with Rails! • Design pattern from Martin Fowler’s book Patterns of Enterprise Application Architecture (2002) • “An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.”

  6. Goals of Active Record • Make working with databases easier • Reduce repetition in code • Cut down on configuration needed to make applications work

  7. Migrations

  8. Migration Data Types mysql openbase oracle postgresql sqlite sqlserver db2 :binary blob(32768) blob object blob bytea blob image :boolean decimal(1) tinyint(1) boolean number(1) boolean boolean bit date date date :date date date date datetime datetime datetime date :datetime timestamp timestamp datetime datetime :decimal decimal decimal decimal decimal decimal decimal decimal float float number :float float float float float(8) int(11) integer number(38) :integer int integer integer int varchar(255) char(4096) varchar2(255) :string varchar(255) (note 1) varchar(255) varchar(255) text text clob :text clob(32768) text text text time time date :time time time datetime datetime datetime timestamp date :timestamp timestamp timestamp datetime datetime

  9. Class versus table names

  10. Plurals vs. Singular in Rails OwnersController Pet model owners table has_many :pets belongs_to :owner @owner.pets @pet.owner

  11. Relationships (see examples in PATS)

  12. ActiveRecord creates SQL (examples given in class)

  13. Controllers in charge • Basic actions include: index, show, new, create, edit, update, delete • Controllers get needed data from models first • Actions connected automatically to view pages Key Idea : Controller handle the process logic

  14. All about views • CSS and images • Layouts • Partials Key Idea : Views only know what controllers tell them

  15. Comic of the Day...

  16. pItlh

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend