6.9 Actors I


#1

CODE:
routes.rb

Rails.application.routes.draw do
  get "/movies" => "movies#index"
  get "/movies/:id" => "movies#show", as: :movie
  get "/actors" => "actors#index"
  get "/actors/:id" => "actors#show", as: :actor
end

actors/index.html.erb

<div class="main actor-index">
      <div class="container">
        <div class="row">
          <% @actors.each do |a| %>
          	<%= image_tag a.image %>
          	<h3> <%= a.first_name %> <%= a.last_name %> </h3>
          	<p> <%= link_to "Learn more", actor_path(a) %>
          <% end %>          
      </div>
</div>

movies/index.html.erb

<div class="hero">
  <div class="container">
    <h2>Interstellar</h2>
    <p>Former NASA pilot Cooper (Matthew McConaughey) and a team of researchers travel across the galaxy to find out which of three planets could be mankind's new home.</p>
    <a href="#">Read More</a>
  </div>
</div>

<div class="main">
  <div class="container">
  <h2>Popular Films</h2>
    <% @movies.each do |movie| %>
    <div class="movie">
      <%= image_tag movie.image %>
      <h3><%= movie.title %></h3>
      <p><%= movie.release_year %></p>
      <p><%= movie.plot %></p>
      <%= link_to "Learn more", movie_path(movie) %>
    </div>
    <% end %>
  </div>
</div>

ERROR MESSAGE:
Uploading...

LINK TO LESSON


#2

Hey @snaylz,

I'm not seeing any problems in your code, and the error message didn't finish uploading. Could you try uploading it again, please?


#3

Uploading...

It's not letting me upload for some reason. Try viewing it using this link :

Cheers.


#4

@snaylz Have you defined the @actors variable in your Actors' index action?


#5

@zystvan - Would that mean writing @actors = Actors.all ?

If so, no I haven't done that, yet!


#6

@snaylz Correct, you'll need to do that. Although it should be @actors = Actor.all (singular Actor the second time) :slight_smile:


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.