To Lecture Notes

IT 232 -- 10/7/15

Review Exercises

Use these documents to help you with the review exercises:
     FormTagHelper vs. FormHelper Methods
     ActiveRecord Queries

  1. Write a form tag with, action confirmation in the controller deposit. Ans:
    <%= form_tag 'confirmation' do %>
    
    or
    <%= form_tag deposit_confirmation_path do %>
    
  2. Write a textfield tag with name ssn, initial value Enter SSN, and CSS class ctrl. Ans:
    <%= text_field_tag :ssn, 'Enter SSN', class: 'ctrl' %>
  3. Write a submit tag with caption Submit Data and CSS class ctrl. Ans:
    <%= submit_tag 'Submit Data', class: 'ctrl' %>
  4. Modify the TemperatureConverter1 project to:
    1. include another textfield on the input view for entering a name,
    2. when the submit button is clocked, enter the name, the Celsius temperature, and the Fahrenheit temperature in a database table with model name TempConvertRecord
    3. display the records in the database on the display page.
    Ans: See the TemperatureConverter2 Example.

Many-to-many Relationships

A Modification to the School1 Example

  1. In the School1 Example, replace the dropdown list in the Student show view with radio buttons.
    Ans: Replace this dropdown menu code in the Student show view
    <%= select_tag(:course,
          options_from_collection_for_select(
              @student.unenrolled_courses, :id, :course_num)) %>
      
    
    with this code that creates radio buttons:
     <% @student.unenrolled_courses.each do |course| %>
      <%= radio_button_tag(:course, course.id, checked: false) %> 
                                         <%= course.course_num %><br> 
    <% end %>
    

Project 3