class MoviesController < ApplicationController
def index
@movies = Movie.all
end
def show
@movie = Movie.find(params[:id])
@actors = @movie.actors
end
end
如上所示,在索引操作中使用了@movies,但在show操作中使用了@movie。如何確定它是複數還是單數?在Ruby on Rails中,爲什麼有時在控制器中,它是複數,有時它是單數?
您需要閱讀它們映射到的Rails和http動詞中的動作。 [對於初學者](http://guides.rubyonrails.org/routing.html) –