To Examples

PhotoGallery Example

Directions

  1. Create a new Rails project named PhotoGallery.
  2. Generate a Rails scaffold named Photo with these fields.
    Field Datatype
    description boolean
    filename boolean
  3. Modify the Photo index view to use this source code: index.html.erb.
  4. In the controller file PhotoGallery/app/controllers/photos_controller.rb, in the index action, replace the line
    @photos = Photo.all
    
    with
     @photos = Photo.order(created_at: 'desc' ).all
    
  5. Download and unzip the photos in dogs-owners.zip into the folder PhotoGallery/apps/assets/images.
  6. View the show pages with this URLs:
    http://localhost:3000/photos