Best way to extract .js.erb from the page
If I have shared javascript infused with erb shared across two pages, (in my case looking up a route) how and where is the best place to extract that .js.erb file? Options as I see them:
- Extrapolate the status quo t开发者_StackOverflow中文版o 2 copies of the same code on two pages (ugh...)
- Extract the
.js.erbinto a file and keep it in the view folder. - Extract the
.js.erbinto a file somewhere in public/javascripts.
What would you do in this case?
SOLVED: Extracted into an html.erb partial in the views folder, from where it is accessible to both new and edit actions for that controller. This solves the redundancy problem while keeping it in a logical place.
加载中,请稍侯......
精彩评论