Movies II 5.3


#1

Hi,

at the moment I'm stuck at this part of the course. The instructions goes as follows

  1. In app/view/movies/show.html.erb

Inside

...
, display the movie's image, title, release year, and plot.

Below

Cast

, iterate through each actor and display the image, first name, last name, and bio.

code : app/view/movies/show.html.erb

<div class="main movie-show">
  <div class="container">
    <div class="movie">
      <% @movies.each do |movie| %>
      <div class="info">
        <%= image_tag movie.image %>
        <h3 class="movie-title"> <%= movie.title %> </h3>
        <p class="movie-release-year"> <%= movie.release_year %> </p>
        <p class="movie-plot"> <%= movie.plot %> </p>
      </div>
      <% end %>
    </div>

    <h2>Cast</h2>
    <% @actors.each do |actor| %>
    <div class="actor">
      <%= image_tag @actor.image %>
      <h3 class="actor-name"> <%= @actor.first_name %> <%= @actor.last_name %> </h3>
      <p class="actor-bio"> <%= @actor.bio %> </p>
    </div>
    <% end %>

  </div>
</div>

code of Movies controller

class MoviesController < ApplicationController
	def index
		@movies = Movie.all
	end
  
  def show
    @movie = Movie.find(params[:id])
    @actors = @movie.actors
  end
end

Any help is welcome. thank you


#2

You forgot this to permit movie_params:

class MoviesController < ApplicationController
#index, show, etc.
private
    def movie_params
      params.required(:movie).permit(:id)
    end
end

#3

Hi blogninja85673 - did hemavidal's solution work? did you get past this step? stuck here also with pretty much the same code. thanks.


#4

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