">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 142 Lecture Notes: Rails Controllers and ViewsSlide 1 Simple Rails Template

Similar presentations


Presentation on theme: "CS 142 Lecture Notes: Rails Controllers and ViewsSlide 1 Simple Rails Template "— Presentation transcript:

1 CS 142 Lecture Notes: Rails Controllers and ViewsSlide 1 Simple Rails Template Hello, User This page was fetched at

2 CS 142 Lecture Notes: Rails Controllers and ViewsSlide 2 Control Structures in Templates ?xml version="1.0" encoding="utf-8"?> Rails Parameters The params hash contains the following values: :

3 CS 142 Lecture Notes: Rails Controllers and ViewsSlide 3 Control Structures, cont’d... :... :... x: 44 y: 92 action: showParams controller: rails_intro... x: 44 y: 92 action: showParams controller: rails_intro... Template: HTML:

4 CS 142 Lecture Notes: Rails Controllers and ViewsSlide 4 Controller: Compute Primes class RailsIntroController < ApplicationController def show_primes if params[:count] != nil then count = params[:count].to_i() else count = 10 = [] candidate = 2 < count is_prime = do |prime| if (candidate % prime) == 0 then is_prime = false break end if is_prime << candidate end candidate += 1 end Query value determines # primes to compute Fill array with prime numbers

5 CS 142 Lecture Notes: Rails Controllers and ViewsSlide 5 Template to Display Primes Prime Numbers The first prime numbers are: Prime Numbers ">

6 Directory Structure CS 142 Lecture Notes: Rails Controllers and ViewsSlide 6 app rails_intro views models controllers rails_intro_controller.rb student_controller.rb hello.html.erb show_params.html.erb show_primes.html.erb student stylesheets main.css db migrate assets javascripts images

7 CS 142 Lecture Notes: Rails Controllers and ViewsSlide 7 Layouts app/views/layouts/application.html.erb: This page was fetched at app/views/rails_intro/hello.html.erb:

8 CS 140 Lecture Notes: File SystemsSlide 8


Download ppt "CS 142 Lecture Notes: Rails Controllers and ViewsSlide 1 Simple Rails Template "

Similar presentations


Ads by Google