A web application is being created with rails.
Like YouTube, I want to create a screen with thumbnails arranged,
I want to call a partial template with render partial:
If i use a variable in the plate, it will be "NameError in Dashboard # index".
The following error screen is displayed.
Applicable source code▼/app/views/dashboard/index.html.haml
= render 'layouts/hedder'
#content
.main
= render 'layouts/page_top'
.dashboard
= image_tag "cover", class: 'cover-img', alt: ""
#info
.popularity
% h2.heading popular videos
% ul.movie-box
= render partial: 'layouts/movie-box', collection: @chapter
▼/chapter-tube/app/views/layouts/_movie-box.html.haml
% li.movie-box--list
= link_to "#" do
= image_tag "http://img.youtube.com/vi//sddefault.jpg", class: 'movie-box--list--thumb', alt: "# {chapter.title}"
.chapter-title
= chapter.title
.chapter-pray-time 00:30
▼/chapter-tube/app/controllers/dashboard_controller.rb
class DashboardController
Check if the variable doesn't pass well to the render destination
https://qiita.com/bambis13s/items/015f5bf921eb820ef652
I tried many things with reference to this article, but the error content did not change, so
I want you to point out!
-
Answer # 1
-
Answer # 2
In error message, chapter is incorrect @chapter It may be.
Is the chapter used in _movie-box.html.haml the same as @chapter in the calling index? Is it different?
If it is the same, you can use @chapter.
If it's different, it's supposed to be crossed, but how was it?
Related articles
- ruby on rails - nameerror in contacts # index
- ruby on rails - nameerror in looks # index
- slim - nameerror in ruby on rails
- ruby on rails - i want to resolve rails nameerror
- ruby - [rails] about nameerror
- ruby - i want to solve nameerror in posts # index with asynchronous like function [rails]
- ruby - i want to cancel nameerror in prototypes # index
- ruby on rails - i want to resolve nameerror in micropostscontroller # search
- ruby on rails - saved description in nested controller
- ruby on rails - cart function routing error cannot be resolved
- ruby on rails - rails s can't
- ruby on rails - how to transition from the top page
- ruby on rails - i want to implement a function for administrator users to register luggage for general users in rails
- ruby on rails - things associated with a foreign key cannot be called in view
- ruby on rails 6 - environment construction of ruby on rails
- ruby on rails - rails6 rspec model run-time error nomethoderror: undefined method `valid?'for nil: nilclass
- ruby on rails 5 - actioncontroller :: invalidauthenticitytoken cannot be resolved
- ruby on rails - error in controller when transitioning with rails6 destory action
- ruby on rails - access fails after seed after deploying to heroku
- ruby on rails runtime error cannot be resolved
- css - the post list is displayed sideways
- javascript - [js] please tell me why addeventlistener does not work for the acquired object
- ruby on rails 5 - haml cannot be read
- ruby - underline does not disappear after using link_to
- style: i want to replace the image display directly written in html with "background-image" with image_tag
- ruby - cannot edit files by introducing devise function
- ruby - error when logging in and creating a new one by introducing the devise function
- ruby - unable to send message
- ruby - message sent and not reflected in view
- ruby - not reflected in view when sending message
Rails guide # Rendering collections
movie-box
is invalid as a variable name, so I don't know what variable is actually prepared, butIn such a case, you should specify it explicitly with
: as
.