Download presentation

Presentation is loading. Please wait.

Published byKeon Clarkin Modified over 2 years ago

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 end @primes = [] candidate = 2 while @primes.length < count is_prime = true @primes.each do |prime| if (candidate % prime) == 0 then is_prime = false break end if is_prime then @primes << candidate end candidate += 1 end Query value determines # primes to compute Fill in @primes 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

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google