Rails 3 does not load HAML handler

I am having problems with Rails 3 and HAML in my application: for some reason, Rails does not seem to load a handler for working with haml files. Each action gives an error message similar to this:


Missing template

The contact_search / index template is missing using {: formats => [: html] ,: handlers => [: rjs ,: rhtml ,: rxml ,: builder ,: erb] ,: locale => [: en ,: en]} in the viewing path "/ var / www / osphonebook / app / views", "/var/www/osphonebook/vendor/bundle/ruby/1.8/gems/devise-1.3.4/app/views"


Look at the "handlers" options: it doesn't have: haml ...

The fact is that this only happens in production mode on a server created by my company. In development and testing mode, it works fine. Also, if I run the application in production mode on my development computer, it works.

Some server information:

UPDATE (6/6/2011): Updated to Ruby 1.9 , and it still does not work.

ruby 1.9.2p0 (2010-08-18 revision 29036) [i486-linux] Gems included by the bundle: abstract (1.0.0) actionmailer (3.0.7) actionpack (3.0.7) activemodel (3.0.7) activerecord (3.0.7) activeresource (3.0.7) activesupport (3.0.7) arel (2.0.10) bcrypt-ruby (2.1.4) builder (2.1.2) bundler (1.0.14) devise (1.3.4) erubis (2.6.6) haml (3.1.1) i18n (0.5.0) kgio (2.4.1) mail (2.2.19) mime-types (1.16) orm_adapter (0.0.5) pg (0.11.0) polyglot (0.3.1) rack (1.2.3) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.7) railties (3.0.7) rake (0.8.7) sass (3.1.2) sqlite3 (1.3.3) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.27) unicorn (3.6.2) warden (1.0.4) 

If you need more information, please comment on the question and I will update it. Thanks for any help.

+6
source share
4 answers

I found the problem: I modified the config/environments/production.rb file to set a personalized code for ActionMailer. The fact is that I used the class directly, for example:

 ActionMailer::Base.delivery_method = :sendmail ActionMailer::Base.raise_delivery_errors = true ActionMailer::Base.charset = "utf-8" 

instead of this:

 config.action_mailer.delivery_method = :sendmail config.action_mailer.raise_delivery_errors = true config.action_mailer.charset = "utf-8" 

It seems that using the ActionMailer class directly launched ActionView loaders and set all the internal variables, preventing the HAML code from being set.

After changing the code, it worked like a charm.

+5
source

Try it with the haml-rails gem

+5
source

I found a solution to the "missing HAML template" error when working in production mode (using Rails 3.2.6 and haml-rails 0.3.4):

In /config/application.rb it has

 if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end 

I changed it to

 if defined?(Bundler) # If you precompile assets before deploying to production, use this line # Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line Bundler.require(:default, :assets, Rails.env) end 

And now it works.

+2
source

Is there any addition

 require "haml" 

to config/test.rb (and / or development.rb and production.rb ) fix this for you?

(Note that I am using Rails 3.2.2)

0
source

Source: https://habr.com/ru/post/889697/


All Articles