最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Rails gem with javascript files - Stack Overflow

programmeradmin2浏览0评论

I'm trying to create a ruby gem for rails out of a plugin I've created. The problem is that my plugin 'shortcuts' uses a few javascript files which need to be in the public/javascripts directory to work.

What's the best way to make these javascript files which are in the gem I've created accessible by which ever project requires my gem?

I'm trying to create a ruby gem for rails out of a plugin I've created. The problem is that my plugin 'shortcuts' uses a few javascript files which need to be in the public/javascripts directory to work.

What's the best way to make these javascript files which are in the gem I've created accessible by which ever project requires my gem?

Share Improve this question edited Oct 30, 2009 at 23:42 Ryan Bigg 108k25 gold badges241 silver badges263 bronze badges asked Oct 30, 2009 at 2:13 map7map7 5,1266 gold badges74 silver badges131 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Add a rails generator to your gem such that script/generate <yourgem> puts the javascript files in the correct location.

For more information, see the How to Make a Generator Railscast.

As an example, the formtastic gem has a generator that puts its specific stylesheets in the correct location -- similar to your javascript problem.

Another example, nifty-generators is just a gem with useful generators.

You could copy them over by making a postinstall.rb which will be automatically executed after your plugin is installed.

发布评论

评论列表(0)

  1. 暂无评论