<html> Ans: <html>
<IMG SRC=myphoto.jpg>Ans: (1) IMG should be lower case, (2) SRC should be lower case, (3) myphoto.jpg should be in double quotes, (4) the tag should be a combination start-end tag, ending in / >. The corrected tag is:
<img src="myphoto.jpg" />
<!-- HTML Comment --> /* CSS Comment */ // JavaScript Comment # Ruby Comment
| Action | DOS | Mac Unix |
|---|---|---|
| Delete File | del | rm |
| Create Folder | mkdir | mkdir |
| List Files in Folder | dir | ls |
| Move to Parent Folder | cd .. | cd .. |
| Move to Child Folder | cd folder-name | cd folder-name |
| Move to Root Folder | cd \ | cd / |
| Change to Different Drive | f: | cd /Volumes/f |
| Show File Contents on Screen | type | cat |
| Delete File | del | rm |
def index @title = "Index" end def staff @title = "Staff" end def policies @title = "Policies" end
<html> <head> <title> <%= @title %> Page </title> </head> <body> <h1> <%= @title %> Page </h1> <p>This is the <%= @title %> page.</p> </body> </html>
http://localhost:3000/info/index
http://rubyserver.cdm.depaul.edu/info/index
get 'info/index' get 'info/policies' get 'info/staff'
http://localhost:3000/photos/pets/23displays the pet with id=23.
<%= image_tag 'image.jpg' %>
<%= stylesheet_link_tag 'styles' %>Place the stylesheet in the public/stylesheets folder.
<%= link_to 'To Page 1', {:action => 'page1'} %>
"To Page 1" is the hyperlink text.
<%= image_tag 'car.jpg' %>
<img src="/images/car.jpg" alt="Car" />
<%= image_tag 'dogs/image.jpg' %>
<img src="/images/dogs/collie.jpg" alt="Image" />
<%= image_tag 'car.jpg', :alt => 'Ford Taurus' %>
<img src="/images/car.jpg" alt="Ford Taurus" />
<%= image_tag 'car.jpg', :size => '250x200' %>
<img src="/images/car.jpg" height="250" width="200" alt="Car" />
<%= image_tag 'car.jpg', :width => '250' %>
<img src="/images/car.jpg" height="250" alt="Car" />
<%= image_tag 'car.jpg', :class => 'carimg' %>
<img src="/images/car.jpg" class="carimg" alt="Car" />
Reference:
api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html
<%= stylesheet_link_tag 'styles.css' %>
<link rel="stylesheet" type="text/css" media="screen"
href="stylesheets/styles.css" >
<%= stylesheet_link_tag 'styles' %>
<link rel="stylesheet" type="text/css" media="screen"
href="stylesheets/styles.css" >
<%= stylesheet_link_tag 'dogs/styles' %>
<link rel="stylesheet" type="text/css" media="screen"
href="stylesheets/dogs/styles.css" >
<%= stylesheet_link_tag 'styles', 'dogs/canines' %>
<link rel="stylesheet" type="text/css" media="screen"
href="stylesheets/styles.css" >
<link rel="stylesheet" type="text/css" media="screen"
href="stylesheets/dogs/canines.css" >
<%= stylesheet_link_tag 'styles', :media => 'print' %>
<link rel="stylesheet" type="text/css" media="print"
href="stylesheets/styles.css" >
<%= stylesheet_link_tag :all, :media => 'print' %>
Link to all stylesheets in stylesheets folder.
Reference:
api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html
<%= link_to 'To Profiles/Show Page', {:controller => 'profiles', :action => 'show'} %>
<href="/profiles/show">To Profile Page</a>
<%= link_to 'To Profiles/Index Page', {:controller => 'profiles', :action => 'index'} %>
<href="/profiles/index">To Index Page</a>
<%= link_to 'To Profile/Show Page', {:action => 'show'} %>
<href="/profiles/show">To Profile</a>
<%= link_to 'To Profile/Show Page', {:action => 'show'}, :class='link' %>
<href="/profiles/show" class="link">To Profile Page</a>
<%= link_to 'To Profile/Show Page', {:action => 'show'}, :id='linka' %>
<href="/profiles/show" class="linka">To Profile Page</a>
<%= link_to 'To Profile/Show Page', {:action => 'show'}, :class='link', :id='linka' %>
<href="/profiles/show" class="link" id="linka">To Profile Page</a>
<%= link_to 'To Profile/Show Page', {:action => 'show'}, :confirm => 'Are you sure?' %>
<href="/profiles/show" ">To Profile Page</a>
Need JavaScript code to show an alert box.
Reference:
api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html
| :string | A string of characters. |
| :text | A string of characters, generally longer than a string, which can contain more than one line. |
| :integer | A positive, negative, or zero number without a fractional part; for example 238372, -3273, 0. Integers are represented in binary. |
| :float | A positive, negative, or zero floating point number, which can contain a decimal point; for example 345.39, -438.86, 0.00. Floats are also represented in binary. |
| :decimal | A positive, negative, or zero floating point number, which can contain a decimal point. Decimal numbers are represented in base 10 and are accurate for financial calculations. |
| :datetime | A combination type that represents a date and time to the nearest millisecond. |
| :timestamp | Used to mark when a row is entered in a database. |
| :time | The hour, minute, and second of the time recorded in the database. |
| :date | The year, month, and day of the date recorded in the database. |
| :binary | Unstructured binary data (sometimes called a BLOB for binary large object). This may be compressed data that is uncompressed when it is retrieved from the database, or it may be image or sound data. |
| :boolean | Contains a 0 or 1 that represents false or true. |
rails generate scaffold MovieReview movie_name:string reviewer_name:string review:text review:integer review_date:date recommended:boolean
rake db:migrate
| Resource Name | movie_reviews |
| Database Table Name | movie_reviews |
| Model Name | MovieReview |
| Controller Name | MovieReviewController |
| View Folder Name | movie_reviews |
| Resource Name | person |
| Database Table Name | people |
| Model Name | Person |
| Controller Name | PersonController |
| View Folder Name | people |
get "info/staff"
resources :movie_reviews