module Orchestrate::Rails::Tutorial::TheShowAction

Adding the show action

We'll add the show action to the controller to display the film's information.

Updating the films controller.

Update <rails-root>/app/controllers/films_controller.rb to add the show action:

class FilmsController < ApplicationController

  def index
    @films = Film.all
  end

  def show
    @film = Film.find params[:id]
  end
end

Creating the view for the show action.

Reminder: HAML is quite particular about indentation, so take care to keep the code aligned properly when pasting into your editor.

Create <rails-root>/app/views/films/show.html.haml as shown:

%ul.films.list-group
 %li.list-group-item
  %h3.list-group-item-heading= @film.title
  %ul.list-group
   %li.list-group-item
    = render partial: 'films/film_info'

Now we'll add the partial view that displays a film's information.

Create <rails-root>/app/views/films/_film_info.html.haml as shown:

- @film.attrs.each do |film_attr|
 .row
  .col-md-3.col-md-offset-1.film-heading= film_attr.humanize
  - if film_attr == 'poster'
   .col-md-7= link_to @film.title, @film.poster
  - elsif film_attr == 'imdb_id'
   .col-md-7= link_to @film.title, "http://www.imdb.com/title/#{@film.imdb_id}"
  - else
   .col-md-7= @film.send(film_attr)
.row
 .col-md-3.col-md-offset-1.film-heading= "Primary Key"
 .col-md-7= @film.id

Let's check it out

Now we should be able to follow that broken link!

Next

Getting Orchestrate.io events