Made Cocoon Rails 3.1 compatible:

- moved cocoon.js to app/assets/javascripts
- adapted install-generator accordingly (for rails 3.0.x)
- made it an engine instead of railtie (to use the asset pipeline)
This commit is contained in:
nathanvda 2011-07-23 23:42:01 +02:00
parent 4192f92e64
commit 1628bb19d3
3 changed files with 12 additions and 4 deletions

View File

@ -1,7 +1,7 @@
require 'cocoon/view_helpers'
module Cocoon
class Railtie < ::Rails::Railtie
class Engine < ::Rails::Engine
config.before_initialize do
config.action_view.javascript_expansions[:cocoon] = %w(cocoon)

View File

@ -2,10 +2,18 @@ module Cocoon
module Generators
class InstallGenerator < ::Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
desc "This generator installs the javascript needed for cocoon"
if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR >= 1
# for Rails 3.1 no installing is needed anymore, because of the asset pipeline
desc "Installing is only needed for rails 3.0.x"
def do_nothing
puts "Installing is no longer required since Rails 3.1"
end
else
desc "This generator installs the javascript needed for cocoon"
def copy_the_javascript
copy_file "cocoon.js", "public/javascripts/cocoon.js"
copy_file "../../../app/assets/javascripts/cocoon.js", "public/javascripts/cocoon.js"
end
end
end