- When trying to simplify our routes, I received an error when creating a new movie. In the controller, we show the "movies/new" template if the movie does not satisfy the requirements (i.e. that there is a title/description). However, when I use
render template: "new", I am met with errors when a movie without a title is submitted. If I replace it withrender template: "movies/new", or if I sayrender "new"there is no error. Why is the "movies" not implied in the case where I render a template?
- Answer:
render template:requires the full path (i.e.movies/new) whereasrenderis a shortcut that uses the directory corresponding to the controller
- We learned to replace anchor links with link_to elements. One of our links is an option to delete the movie, and part of the element is
data-method="delete". How do we include that in the syntax for the link_to replacement?
- Answer:
<%= link_to "Delete movie", movie_path(@movie), method: :delete %>
Top comments (0)