I have duplicate js.erb code between different model’s ajax responses. I would like to refactor the duplicate js.erb code by passing arguments into a js.erb partial.
How do i render a js.erb partial from a js.erb file?
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.
Just like you would render any other partial with erb. Let’s say your partial is called
_my_partial.js.erb(note partials always start with_), then in your main.js.erbfile you would do:If your partial is in another directory, just use: