2014-07-19 24 views
12

Rails 4 + Ruby 2.0 projesinde metin editöründe .scss veya .erb dosyasını düzenlerseniz, tarayıcıdaki canlı değişiklikleri görmek istiyorum.Rails 4 ve Ruby 2.0 uygulaması ile nasıl canlı yüklenir?

Guard ve Guard-live-reload'ı denedim, ancak şu hatayı atıyor.

22:58:04 - ERROR - Could not load 'guard/rspec' or find class Guard::Rspec 
22:58:04 - ERROR - /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/plugin_util.rb:100:in `require' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/plugin_util.rb:100:in `plugin_class' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/plugin_util.rb:57:in `initialize_plugin' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard.rb:167:in `add_plugin' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/dsl.rb:174:in `block in guard' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/dsl.rb:173:in `each' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/dsl.rb:173:in `guard' 
> [#] /home/jitendra/milaap-webapp/Guardfile:4:in `_instance_eval_guardfile' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/guardfile/evaluator.rb:97:in `instance_eval' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/guardfile/evaluator.rb:97:in `_instance_eval_guardfile' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/guardfile/evaluator.rb:37:in `evaluate_guardfile' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/setuper.rb:148:in `evaluate_guardfile' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/setuper.rb:64:in `setup' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/commander.rb:24:in `start' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/cli.rb:107:in `start' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/thor-0.19.1/lib/thor/command.rb:27:in `run' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/thor-0.19.1/lib/thor/base.rb:440:in `start' 
> [#] /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/bin/guard:6:in `<top (required)>' 
> [#] /home/jitendra/.rvm/gems/[email protected]/bin/guard:23:in `load' 
> [#] /home/jitendra/.rvm/gems/[email protected]/bin/guard:23:in `<main>' 
> [#] /home/jitendra/.rvm/gems/[email protected]/bin/ruby_executable_hooks:15:in `eval' 
> [#] /home/jitendra/.rvm/gems/[email protected]/bin/ruby_executable_hooks:15:in `<main>' 
22:58:04 - ERROR - Invalid Guardfile, original error is: 
> [#] undefined method `superclass' for nil:NilClass 
/home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/plugin_util.rb:57:in `initialize_plugin': undefined method `superclass' for nil:NilClass (NoMethodError) 
    from /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard.rb:167:in `add_plugin' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/dsl.rb:174:in `block in guard' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/dsl.rb:173:in `each' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/dsl.rb:173:in `guard' 
    from /home/jitendra/milaap-webapp/Guardfile:4:in `_instance_eval_guardfile' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/guardfile/evaluator.rb:97:in `instance_eval' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/guardfile/evaluator.rb:97:in `_instance_eval_guardfile' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/guardfile/evaluator.rb:37:in `evaluate_guardfile' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/setuper.rb:148:in `evaluate_guardfile' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/setuper.rb:64:in `setup' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/commander.rb:24:in `start' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/lib/guard/cli.rb:107:in `start' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/thor-0.19.1/lib/thor/command.rb:27:in `run' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/thor-0.19.1/lib/thor/base.rb:440:in `start' 
    from /home/jitendra/.rvm/gems/[email protected]/gems/guard-2.6.1/bin/guard:6:in `<top (required)>' 
    from /home/jitendra/.rvm/gems/[email protected]/bin/guard:23:in `load' 
    from /home/jitendra/.rvm/gems/[email protected]/bin/guard:23:in `<main>' 
    from /home/jitendra/.rvm/gems/[email protected]/bin/ruby_executable_hooks:15:in `eval' 
    from /home/jitendra/.rvm/gems/[email protected]/bin/ruby_executable_hooks:15:in `<main>' 

cevap

17

i livereload ile çalışmak nasıl budur:

1.) sizin Gemfile yılında gem

alın:

group :development do 
    gem 'guard-livereload', require: false 
end 

2.)guard init livereload, hangisi Uygulamanızın kökünde bir Guardfile oluşturur.

3.) senin Guardfile diğer bekçi eklentileri onlar livereload altında kalmak çalıştırırsanız o, (bu gibi sadece Guard-Livereload görünmelidir açılması.)

guard 'livereload' do 
    watch(%r{app/views/.+\.(erb)$}) 
    watch(%r{app/helpers/.+\.rb}) 
    watch(%r{public/.+\.(css|js|html)}) 
    watch(%r{config/locales/.+\.yml}) 
    watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" } 
end 

4.) senin sunucuyu yeniden başlatın) Chrome Web Store

5'ten Livereload Chrome Uygulamasını alın ve ayrı bir sekme açmak ve tip->guard

Diğer en aynı soruya denk olabilecek için yoğun yazdım (Guard Sekmesi'ndeki Bağlı Tarayıcı)

sizin Tarayıcıda

6.) livereload düğmeye basmak ve bunu bağlanmalıdır. Özel durumunuz için # 3'u okuyun. Korumanızı aç ve önce Livereload'ın arandığından emin ol.

git SSL ile çalışırken Railscast #264 Guard

, livereload oldukça iyi böyle değil izleyin.

Rack-Livereload, SSL sorunlarının üstesinden gelmek için projenize ekleyebileceğiniz temiz bir küçük parçadır. Gem bir parça veya Rack middleware ekler ve temel olarak mevcut (ve SSL etkin) Rails sunucusundan javascript'i sunmak için livereload uygulamasına bağlanır.

+0

23:40:12 - BİLGİ - LiveReload bağlanacak bir tarayıcı için bekliyor. –

+0

Harika, tarayıcınızdaki Livereload düğmesine basın. –

+0

tamam, bu, .erb dosyasında değişiklik yaptıktan sonra çıktı http://pastebin.com/SeLfx7qr da sayfa yenilenmedi –