SlideShare a Scribd company logo
YOUR FIRST RAILS APP
                              Environments, MVC, Scaffold




Sunday, November 13, 11
CREATING YOUR FIRST RAILS APP

                                   rails new roster

                          This command generates code for
                              a new Rails web application 
                           in a sub-directory called “roster”  




Sunday, November 13, 11
THE APPLICATION DIRECTORY
       • The whole rails app is in this one directory
           • No hidden configuration files in system directories
           • You will modify many of these files in the course of your development
           • We're using sqlite so even the database is in this directory, but usually the
             database is the only part of your application that lives somewhere else
       • You can simple copy this directory to server to deploy the app
       • You can delete the directory and its contents
         if you want to throw it away and start over




Sunday, November 13, 11
RUNNING YOUR APP

                                cd roster
                                 bundle
                               rails server 




Sunday, November 13, 11
RAILS ENVIRONMENTS
       By default, Rails is configured with 3 environments:
         • development
         • test
         • production




Sunday, November 13, 11
RAILS ENVIRONMENTS




Sunday, November 13, 11
RAILS ENVIRONMENTS




Sunday, November 13, 11
RAILS ENVIRONMENTS
       The environment can be specified with
       	

 RAILS_ENV as an environment variable
           "development" by default.

       In your code, you refer to Rails.env
       (or RAILS_ENV in Rails 2)




Sunday, November 13, 11
CONFIG/DATABASE.YML




Sunday, November 13, 11
ADDITIONAL CONFIGURATION


   config/environments/
     • development.rb
     • production.rb
     • test.rb




Sunday, November 13, 11
MODIFYING THE HOME PAGE

                                  public/index.html

                            All files in the public directory
                                   are static content.

                              Rails checks this directory
                          before executing any dynamic code.




Sunday, November 13, 11
MVC




Sunday, November 13, 11
LEARNING WITH SCAFFOLD

   rails generate scaffold
      person first_name:string last_name:string




Sunday, November 13, 11
NAMING CONVENTIONS




Sunday, November 13, 11
SCAFFOLD
       Model
          app/models/person.rb
          db/migrate/20090611073227_create_people.rb

       5 views
           app/views/people/index.html.erb
           app/views/people/show.html.erb
           app/views/people/new.html.erb
           app/views/people/edit.html.erb
           app/views/people/_form.html.erb

       Controller
          app/controllers/people_controller.rb
          route.rb: resources :people

Sunday, November 13, 11
MVC
       Model: ActiveRecord
       •Represents what is in the database

       View: ActionView, erb
       •Model rendered as HTML

       Controller: ActionController
       •Receives HTTP actions (GET, POST, PUT, DELETE)
       •Decides what to do, typically rendering a view
Sunday, November 13, 11
VIEWS

   <% @people.each do |person| %>
   <tr>
   	

 <td><%= person.first_name %></td>
       <td><%= person.last_name %></td>
   </tr>
   <% end %>




Sunday, November 13, 11
VIEW EXERCISE

   On the main people page 
   	

 a. Change “Listing people” to “My Class List” 
   	

 b. List people with first initial and last name in one visual
       column (e.g. W. Flintstone) 




Sunday, November 13, 11
Ad

More Related Content

What's hot (20)

Laravel presentation
Laravel presentationLaravel presentation
Laravel presentation
Toufiq Mahmud
 
Ruby on Rails workshop for beginner
Ruby on Rails workshop for beginnerRuby on Rails workshop for beginner
Ruby on Rails workshop for beginner
Umair Amjad
 
Laravel overview
Laravel overviewLaravel overview
Laravel overview
Obinna Akunne
 
Laravel 5.4
Laravel 5.4 Laravel 5.4
Laravel 5.4
Nisha Patel
 
Laravel Eloquent ORM
Laravel Eloquent ORMLaravel Eloquent ORM
Laravel Eloquent ORM
Ba Thanh Huynh
 
Weblogic Console Customization
Weblogic Console CustomizationWeblogic Console Customization
Weblogic Console Customization
Peter van Nes
 
Weblogic Console Customization labs
Weblogic Console Customization labsWeblogic Console Customization labs
Weblogic Console Customization labs
Peter van Nes
 
Laravel Tutorial PPT
Laravel Tutorial PPTLaravel Tutorial PPT
Laravel Tutorial PPT
Piyush Aggarwal
 
Mule tcat server - Server profiles
Mule tcat server - Server profilesMule tcat server - Server profiles
Mule tcat server - Server profiles
Shanky Gupta
 
Laravel
LaravelLaravel
Laravel
SitaPrajapati
 
Getting to know Laravel 5
Getting to know Laravel 5Getting to know Laravel 5
Getting to know Laravel 5
Bukhori Aqid
 
JBoss, Rails and the cloud
JBoss, Rails and the cloudJBoss, Rails and the cloud
JBoss, Rails and the cloud
elliando dias
 
Database migration with flyway
Database migration  with flywayDatabase migration  with flyway
Database migration with flyway
Jonathan Holloway
 
Presentation laravel 5 4
Presentation laravel 5 4Presentation laravel 5 4
Presentation laravel 5 4
Christen Gjølbye Christensen
 
MuleSoft ESB Composite Source
MuleSoft ESB Composite SourceMuleSoft ESB Composite Source
MuleSoft ESB Composite Source
akashdprajapati
 
Laravel introduction
Laravel introductionLaravel introduction
Laravel introduction
Simon Funk
 
Maven Fundamentals
Maven FundamentalsMaven Fundamentals
Maven Fundamentals
Alok Vishwakarma
 
MySqL Failover by Weatherly Cloud Computing USA
MySqL Failover by Weatherly Cloud Computing USAMySqL Failover by Weatherly Cloud Computing USA
MySqL Failover by Weatherly Cloud Computing USA
Harry Gonzalez
 
Ch. 13 filters and wrappers
Ch. 13 filters and wrappersCh. 13 filters and wrappers
Ch. 13 filters and wrappers
Manolis Vavalis
 
MySQL Failover - Cubexs Weatherly
MySQL Failover - Cubexs WeatherlyMySQL Failover - Cubexs Weatherly
MySQL Failover - Cubexs Weatherly
Weatherly Cloud Inc.
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentation
Toufiq Mahmud
 
Ruby on Rails workshop for beginner
Ruby on Rails workshop for beginnerRuby on Rails workshop for beginner
Ruby on Rails workshop for beginner
Umair Amjad
 
Weblogic Console Customization
Weblogic Console CustomizationWeblogic Console Customization
Weblogic Console Customization
Peter van Nes
 
Weblogic Console Customization labs
Weblogic Console Customization labsWeblogic Console Customization labs
Weblogic Console Customization labs
Peter van Nes
 
Mule tcat server - Server profiles
Mule tcat server - Server profilesMule tcat server - Server profiles
Mule tcat server - Server profiles
Shanky Gupta
 
Getting to know Laravel 5
Getting to know Laravel 5Getting to know Laravel 5
Getting to know Laravel 5
Bukhori Aqid
 
JBoss, Rails and the cloud
JBoss, Rails and the cloudJBoss, Rails and the cloud
JBoss, Rails and the cloud
elliando dias
 
Database migration with flyway
Database migration  with flywayDatabase migration  with flyway
Database migration with flyway
Jonathan Holloway
 
MuleSoft ESB Composite Source
MuleSoft ESB Composite SourceMuleSoft ESB Composite Source
MuleSoft ESB Composite Source
akashdprajapati
 
Laravel introduction
Laravel introductionLaravel introduction
Laravel introduction
Simon Funk
 
MySqL Failover by Weatherly Cloud Computing USA
MySqL Failover by Weatherly Cloud Computing USAMySqL Failover by Weatherly Cloud Computing USA
MySqL Failover by Weatherly Cloud Computing USA
Harry Gonzalez
 
Ch. 13 filters and wrappers
Ch. 13 filters and wrappersCh. 13 filters and wrappers
Ch. 13 filters and wrappers
Manolis Vavalis
 

Similar to Your first rails app - 2 (20)

Active Record Introduction - 3
Active Record Introduction - 3Active Record Introduction - 3
Active Record Introduction - 3
Blazing Cloud
 
Introduction to Rails
Introduction to RailsIntroduction to Rails
Introduction to Rails
Blazing Cloud
 
Rails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_manyRails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_many
Blazing Cloud
 
Activiti & Vaddin
Activiti & VaddinActiviti & Vaddin
Activiti & Vaddin
Alfresco Software
 
Aspose pdf
Aspose pdfAspose pdf
Aspose pdf
Jim Jones
 
Curso rails
Curso railsCurso rails
Curso rails
Icalia Labs
 
Unlocked London - Technical Track
Unlocked London - Technical TrackUnlocked London - Technical Track
Unlocked London - Technical Track
Wayne Walls
 
Rails
RailsRails
Rails
SHC
 
Ruby on Rails
Ruby on RailsRuby on Rails
Ruby on Rails
DelphiCon
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortega
arman o
 
CloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heavenCloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heaven
Patrick Chanezon
 
Rail3 intro 29th_sep_surendran
Rail3 intro 29th_sep_surendranRail3 intro 29th_sep_surendran
Rail3 intro 29th_sep_surendran
SPRITLE SOFTWARE PRIVATE LIMIT ED
 
Building Application With Ruby On Rails Framework
Building Application With Ruby On Rails FrameworkBuilding Application With Ruby On Rails Framework
Building Application With Ruby On Rails Framework
Vineet Chaturvedi
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex
Espen Brækken
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
anides
 
Building Application with Ruby On Rails Framework
Building Application with Ruby On Rails FrameworkBuilding Application with Ruby On Rails Framework
Building Application with Ruby On Rails Framework
Edureka!
 
Coding For Config: Install Profile Development Using Features
Coding For Config: Install Profile Development Using FeaturesCoding For Config: Install Profile Development Using Features
Coding For Config: Install Profile Development Using Features
Myplanet Digital
 
An introduction to Rails 3
An introduction to Rails 3An introduction to Rails 3
An introduction to Rails 3
Blazing Cloud
 
Pocket Knife JS
Pocket Knife JSPocket Knife JS
Pocket Knife JS
Diogo Antunes
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
Lucidworks (Archived)
 
Active Record Introduction - 3
Active Record Introduction - 3Active Record Introduction - 3
Active Record Introduction - 3
Blazing Cloud
 
Introduction to Rails
Introduction to RailsIntroduction to Rails
Introduction to Rails
Blazing Cloud
 
Rails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_manyRails ORM De-mystifying Active Record has_many
Rails ORM De-mystifying Active Record has_many
Blazing Cloud
 
Unlocked London - Technical Track
Unlocked London - Technical TrackUnlocked London - Technical Track
Unlocked London - Technical Track
Wayne Walls
 
Rails
RailsRails
Rails
SHC
 
Ruby on Rails
Ruby on RailsRuby on Rails
Ruby on Rails
DelphiCon
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortega
arman o
 
CloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heavenCloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heaven
Patrick Chanezon
 
Building Application With Ruby On Rails Framework
Building Application With Ruby On Rails FrameworkBuilding Application With Ruby On Rails Framework
Building Application With Ruby On Rails Framework
Vineet Chaturvedi
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex
Espen Brækken
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
anides
 
Building Application with Ruby On Rails Framework
Building Application with Ruby On Rails FrameworkBuilding Application with Ruby On Rails Framework
Building Application with Ruby On Rails Framework
Edureka!
 
Coding For Config: Install Profile Development Using Features
Coding For Config: Install Profile Development Using FeaturesCoding For Config: Install Profile Development Using Features
Coding For Config: Install Profile Development Using Features
Myplanet Digital
 
An introduction to Rails 3
An introduction to Rails 3An introduction to Rails 3
An introduction to Rails 3
Blazing Cloud
 
Ad

More from Blazing Cloud (20)

Rails Class Intro - 1
Rails Class Intro - 1 Rails Class Intro - 1
Rails Class Intro - 1
Blazing Cloud
 
RSpec Quick Reference
RSpec Quick ReferenceRSpec Quick Reference
RSpec Quick Reference
Blazing Cloud
 
Extending rails
Extending railsExtending rails
Extending rails
Blazing Cloud
 
2day Ruby Class Intro
2day Ruby Class Intro2day Ruby Class Intro
2day Ruby Class Intro
Blazing Cloud
 
Mobile Lean UX
Mobile Lean UXMobile Lean UX
Mobile Lean UX
Blazing Cloud
 
Interactive Graphics
Interactive GraphicsInteractive Graphics
Interactive Graphics
Blazing Cloud
 
Interactive Graphics w/ Javascript, HTML5 and CSS3
Interactive Graphics w/ Javascript, HTML5 and CSS3Interactive Graphics w/ Javascript, HTML5 and CSS3
Interactive Graphics w/ Javascript, HTML5 and CSS3
Blazing Cloud
 
Form helpers
Form helpersForm helpers
Form helpers
Blazing Cloud
 
Intro to Ruby (and RSpec)
Intro to Ruby (and RSpec)Intro to Ruby (and RSpec)
Intro to Ruby (and RSpec)
Blazing Cloud
 
What you don't know (yet)
What you don't know (yet)What you don't know (yet)
What you don't know (yet)
Blazing Cloud
 
ActiveRecord
ActiveRecordActiveRecord
ActiveRecord
Blazing Cloud
 
Ruby on Rails Class intro
Ruby on Rails Class introRuby on Rails Class intro
Ruby on Rails Class intro
Blazing Cloud
 
Ruby on rails toolbox
Ruby on rails toolboxRuby on rails toolbox
Ruby on rails toolbox
Blazing Cloud
 
Routes Controllers
Routes ControllersRoutes Controllers
Routes Controllers
Blazing Cloud
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Blazing Cloud
 
Active Record
Active RecordActive Record
Active Record
Blazing Cloud
 
Enumerables
EnumerablesEnumerables
Enumerables
Blazing Cloud
 
Reg EX
Reg EXReg EX
Reg EX
Blazing Cloud
 
Files IO
Files IOFiles IO
Files IO
Blazing Cloud
 
Ruby Blocks
Ruby BlocksRuby Blocks
Ruby Blocks
Blazing Cloud
 
Ad

Recently uploaded (20)

Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 

Your first rails app - 2

  • 1. YOUR FIRST RAILS APP Environments, MVC, Scaffold Sunday, November 13, 11
  • 2. CREATING YOUR FIRST RAILS APP rails new roster This command generates code for a new Rails web application  in a sub-directory called “roster”   Sunday, November 13, 11
  • 3. THE APPLICATION DIRECTORY • The whole rails app is in this one directory • No hidden configuration files in system directories • You will modify many of these files in the course of your development • We're using sqlite so even the database is in this directory, but usually the database is the only part of your application that lives somewhere else • You can simple copy this directory to server to deploy the app • You can delete the directory and its contents if you want to throw it away and start over Sunday, November 13, 11
  • 4. RUNNING YOUR APP cd roster bundle rails server  Sunday, November 13, 11
  • 5. RAILS ENVIRONMENTS By default, Rails is configured with 3 environments: • development • test • production Sunday, November 13, 11
  • 8. RAILS ENVIRONMENTS The environment can be specified with RAILS_ENV as an environment variable "development" by default. In your code, you refer to Rails.env (or RAILS_ENV in Rails 2) Sunday, November 13, 11
  • 10. ADDITIONAL CONFIGURATION config/environments/ • development.rb • production.rb • test.rb Sunday, November 13, 11
  • 11. MODIFYING THE HOME PAGE public/index.html All files in the public directory are static content. Rails checks this directory before executing any dynamic code. Sunday, November 13, 11
  • 13. LEARNING WITH SCAFFOLD rails generate scaffold person first_name:string last_name:string Sunday, November 13, 11
  • 15. SCAFFOLD Model app/models/person.rb db/migrate/20090611073227_create_people.rb 5 views app/views/people/index.html.erb app/views/people/show.html.erb app/views/people/new.html.erb app/views/people/edit.html.erb app/views/people/_form.html.erb Controller app/controllers/people_controller.rb route.rb: resources :people Sunday, November 13, 11
  • 16. MVC Model: ActiveRecord •Represents what is in the database View: ActionView, erb •Model rendered as HTML Controller: ActionController •Receives HTTP actions (GET, POST, PUT, DELETE) •Decides what to do, typically rendering a view Sunday, November 13, 11
  • 17. VIEWS <% @people.each do |person| %> <tr> <td><%= person.first_name %></td> <td><%= person.last_name %></td> </tr> <% end %> Sunday, November 13, 11
  • 18. VIEW EXERCISE On the main people page  a. Change “Listing people” to “My Class List”  b. List people with first initial and last name in one visual column (e.g. W. Flintstone)  Sunday, November 13, 11