Lecture 13b Rails – Controllers and Views Topics SaaSSaaS Readings: SaaS book Ch 4.3-4.5 March 3,...

17
Lecture 13b Rails – Controllers and Views Topics Topics SaaS SaaS Readings: Readings: SaaS book Ch SaaS book Ch 4.3-4.5 4.3-4.5 March 3, 2014 CSCE 740 Software Engineering

Transcript of Lecture 13b Rails – Controllers and Views Topics SaaSSaaS Readings: SaaS book Ch 4.3-4.5 March 3,...

Lecture 13bRails – Controllers and Views

Lecture 13bRails – Controllers and Views

Topics Topics

• SaaSSaaS

Readings: Readings: SaaS book Ch SaaS book Ch 4.3-4.54.3-4.5

March 3, 2014

CSCE 740 Software Engineering

– 2 – CSCE 740 Spring 2014

Rails - Rails -

Last TimeLast Time

SaaSbook 4.1 CreationSaaSbook 4.1 Creationrails new app –Trails new app –TGemfile < haml, debugGemfile < haml, debugrails serverrails serverrake routesrake routesroutes.rbroutes.rb

4.2 Databases/Migrations4.2 Databases/Migrationsrails generate migration rails generate migration create_moviescreate_moviesrake db:migraterake db:migrate

New New

SaaSbook 4.3 ModelsSaaSbook 4.3 Models

app/models/movies.rbapp/models/movies.rb

rake db:migraterake db:migrate

rails console – rails console – walkthroughwalkthrough

rake db:seedrake db:seed

4.4 Controllers, Views4.4 Controllers, Views

movies_controller.rbmovies_controller.rb

views/movies/views/movies/index.html.hamlindex.html.haml

CSSCSS

Next Time:Next Time:

– 3 – CSCE 740 Spring 2014

ResourcesResources

http://rubyonrails.org/

http://guides.rubyonrails.org/

github.com:saasbook/courseware

Installing RailsInstalling Rails http://www.youtube.com/watch?

v=MiAz0DnnY_k&feature=youtu.be http://gorails.com/setup/ubuntu/13.10

http://ruby.railstutorial.org/http://ruby.railstutorial.org/

http://git-scm.com/bookhttp://git-scm.com/book

– 4 – CSCE 740 Spring 2014

Hartl, Michael Hartl, Michael (2012-07-27). (2012-07-27). Ruby on Rails Ruby on Rails Tutorial: Learn Tutorial: Learn Web Web Development Development with Rails (2nd with Rails (2nd Edition)Edition)

– 5 – CSCE 740 Spring 2014

Summary:Summary:

The Haml templating language allows you to The Haml templating language allows you to intersperse HTML tags with Ruby code for your intersperse HTML tags with Ruby code for your views. The result of evaluating Ruby code can either views. The result of evaluating Ruby code can either be discarded or interpolated into the HTML page. be discarded or interpolated into the HTML page.

For conciseness, Haml relies on indentation to reveal For conciseness, Haml relies on indentation to reveal HTML element nesting. HTML element nesting.

Convention over configuration is used to determine Convention over configuration is used to determine the file names for controllers and views the file names for controllers and views corresponding to a given model. corresponding to a given model.

– 6 – CSCE 740 Spring 2014

If the RESTful route helpers are used, as in If the RESTful route helpers are used, as in resources :movies, convention over configuration resources :movies, convention over configuration also maps RESTful action names to controller action also maps RESTful action names to controller action (method) names. (method) names.

Rails provides various helper methods that take Rails provides various helper methods that take advantage of the RESTful route URIs, including advantage of the RESTful route URIs, including link_to for generating HTML links whose URIs refer link_to for generating HTML links whose URIs refer to RESTful actions.to RESTful actions.

– 7 – CSCE 740 Spring 2014

Clipboard SharingClipboard Sharing

– 8 – CSCE 740 Spring 2014

Shared FoldersShared Folders

– 9 – CSCE 740 Spring 2014

Insert Guest AdditionsInsert Guest Additions

– 10 – CSCE 740 Spring 2014

– 11 – CSCE 740 Spring 2014

– 12 – CSCE 740 Spring 2014

– 13 – CSCE 740 Spring 2014

– 14 – CSCE 740 Spring 2014

– 15 – CSCE 740 Spring 2014

– 16 – CSCE 740 Spring 2014

– 17 – CSCE 740 Spring 2014