CS6320:  SW Engineering of Web Based Systems

 

Exercise R2 Ruby on Rails first Web App on Rails

DUE: April. 5 , 11pm

10 points

  • Do a simple Rails project using RubyMine IDE to create a simply hello web app site that also prints the current time. See https://www.youtube.com/watch?v=zWBQBxLeL6
    1. Create Controller class named "SayController" (command line> rails generate controller say -s)
      • RubyMine: Tools->Run Rails Generator
      • RubyMine:  "select controller"
      • RubyMine: give it the name Say
        This generates a new file say_controller.rb file in Controller directory

        generates a View directory called say

        also generates some other files like test, etc.
    2. Now edit SayController class in the say_controller.rb file
      • create a method called hello that does nothing (remember it will at the end automatically call a view called hello.html.erb inside the apps/views folder)
    3. Now create an HTML view file in app/views and make it an ERB file and call it hello.html.erb




      • CALL the file hello.html (NOTE in RUBY mine it will add the erb automatically so the name becomes hello.html.erb)
      • create some static HTML code -- but, make sure in the body to add someHTML to say hello ...this is an erb file with no Ruby in it...all static HTML
      • Now add a Ruby line to print out the current time inside the hello.html.erb file:

        <%= Time.now() %>

    4. Edit the config/routes.rb file so that the URI say/hello will map to calling hello method in the SayController class
      • Basically you add the following to the routes.rb file
        get 'say/hello' => 'say#hello'

     

 

 

DEMONSTRATE - Create YouTube video showing Using your RubyMine IDE and run your project. If your project is NOT working you must show in detail in the video the code you have done (it needs to be readable in the video or you will get 0 points for this) and discuss what errors you are getting.

DELIVERALBES: Turn in YouTube Video to Blackboard->Exercises->Exercise R2

© Lynne Grewe