Lec13-RailsControllersViewsEtc - Computer Science & Engineering

advertisement
CSCE 740 Software Engineering
Lecture 13b
Rails – Controllers and Views
Topics
• SaaS
Readings: SaaS book Ch
4.3-4.5
March 3, 2014
Rails -
New
SaaSbook 4.3 Models
Last Time
SaaSbook 4.1 Creation
 rails new app –T
 Gemfile < haml, debug
 rails server
 rake routes
 routes.rb
4.2 Databases/Migrations
 rails generate migration
create_movies
 rake db:migrate
 app/models/movies.rb
 rake db:migrate
 rails console –
walkthrough
 rake db:seed
4.4 Controllers, Views
 movies_controller.rb
 views/movies/index.ht
ml.haml
 CSS
Next Time:
–2–
CSCE 740 Spring 2014
Resources
http://rubyonrails.org/
 http://guides.rubyonrails.org/
github.com:saasbook/courseware
Installing Rails


http://www.youtube.com/watch?v=MiAz0DnnY_k&feature=youtu.
be
http://gorails.com/setup/ubuntu/13.10
http://ruby.railstutorial.org/
http://git-scm.com/book
–3–
CSCE 740 Spring 2014
Hartl, Michael
(2012-07-27).
Ruby on Rails
Tutorial: Learn
Web
Development
with Rails (2nd
Edition)
–4–
CSCE 740 Spring 2014
Summary:
 The Haml templating language allows you to
intersperse HTML tags with Ruby code for your
views. The result of evaluating Ruby code can either
be discarded or interpolated into the HTML page.
 For conciseness, Haml relies on indentation to reveal
HTML element nesting.
 Convention over configuration is used to determine
the file names for controllers and views
corresponding to a given model.
–5–
CSCE 740 Spring 2014
 If the RESTful route helpers are used, as in
resources :movies, convention over configuration
also maps RESTful action names to controller action
(method) names.
 Rails provides various helper methods that take
advantage of the RESTful route URIs, including
link_to for generating HTML links whose URIs refer
to RESTful actions.
–6–
CSCE 740 Spring 2014
Clipboard Sharing
–7–
CSCE 740 Spring 2014
Shared Folders
–8–
CSCE 740 Spring 2014
Insert Guest Additions
–9–
CSCE 740 Spring 2014
– 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
Download