Home>
I want to achieve
I want to pass the variables written in index.html.slim to _share.html.slim using render partial and locals.
(I want to use variables in the divided files.)
In the following situations, you will get angry if there is no score variable, such as undefined local variable or method `score'. It seems that the score variable has not arrived in _share.html.slim in the first place.
index.html.slim
[email protected] products.zip (@scores) do | product, score |
(~ Various tags ~)
= Render partial:'share', locals: {product: product, score: score}
_share.html.slim
-Puts "# {score}"
-Puts "# {product}"
What I tried
(1) The same thing was described in index.html.slim without dividing the file.
→ Success (displayed without error)
(2) The only variable passed by locals is score.
→ Failure (same error)
(3) The only variable passed in locals is product.
→ Success (displayed without error)
-
Answer # 1
Related articles
- ruby - i'm using the errors method, but i don't get an error message
- [ruby on rails 6] i implemented the tag function using acts-as-taggable-on, but i can't jump to the linked article from the list
- ruby - i get a validation error when using factorybot with rspec
- ruby on rails - variables are not passed to the partial template without reloading
- ruby - i want to collect the same records using rails group and get the value
- ruby - [rails 5] i want to send an email to a specific user using action mailer
- ruby - unable to get initial image when using s3 with active storage
- ruby - [rails] i want to find the date difference using the model created_at
- ruby - [rails] i want to create an image link using the url of the image output using active storage
- about passing ruby arguments (arrays)
- php - about passing value to form using tag
- i want to update the db using variables in pdo in php, but it doesn't work
- c ++ - i want to render text in 3d space using a shader
- ruby - i can't log in with the user management function using devise
- php - regarding passing laravel variables
- java - updating variables using charat ();
- ruby on rails 5 - the url when sign_up using device is strange
- ruby - i want to search the data of a nested model using ransack
- ruby on rails - search function using rails jquery does not work
Related questions
- [ruby] how to write a ternary operator
- I want to write how to write Rails's Helper methods
- ruby - how to implement the edit/update function of multiple tables when using form object in rails
- ruby - all rails gems are not installed
- ruby - output the total integer value held by each user
- ruby - i want to use the search method for active hash data
- ruby - destroy action does not respond
- ruby - how do you see the rails controller relative path? (carrierwave directory deleted)
- ruby - when deploying on capistrano, i get the error "access denied for user'ec2-user' @'localhost' (using password: no)&qu
When I see what I tried
score
It's just a strange thing.First, make sure that double-byte spaces and zero-width spaces are not mixed on both the called/called side.
If that doesn't work,
score
Try using a variable name other than.