开发者

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:

  1. Extrapolate the status quo t开发者_StackOverflow中文版o 2 copies of the same code on two pages (ugh...)
  2. Extract the .js.erb into a file and keep it in the view folder.
  3. Extract the .js.erb into 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜