In Ruby on Rails, can we have some GLOBAL static HTML snippets that we can use in the same way as a helper just like include in php? I’m making a nav bar but sometimes I want it at the bottom of my page.
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use partials:
Create a view which its filename starts with an underscore, for example: /views/shared/_navbar.html.erb
then you can render this partial anywhere you’d like using
in your view.
Note that although the partial file name has an underscore in the beginning, the render states its name with the underscore omitted.