Rails 2.3.2 tries to display ERB instead of HAML

Rails suddenly tries to display ERB instead of Haml, and I cannot understand why. I created new rail projects, reinstalled Haml, and reinstalled Rails.

Here are the exact steps that I take when creating my application (Rails 2.3.2):

  rails> rails test
  rails> cd test
  rails\test> haml --rails .
  rails\test> ruby script\generate model user email:string password:string
  rails\test> ruby script\generate controller users index
  rails\test> rake db:migrate

Here is what UserController looks like:

class UsersController < ApplicationController
  def index
    @users = User.all
  end
end

My routes:

ActionController::Routing::Routes.draw do |map|
  map.resources :users
end

Now I create views \ users \ index.html.haml:

%table
  %th(style="text-align: left;")
    %h1 Users
  - for user in @users
    %tr
      %td= user.email
      %td= user.password

Annnd start the server ... I go to localhost: 3000 \ users and I get this error message:

Template is missing

Missing template users/index.erb in view path app/views

For some reason, Rails is trying to find and display .erb files instead of .haml files. provider \ plugins \ haml \ init.rb exists, untouched.

I reinstalled Haml (Pretty Penny) several times and still get the same results. I also tried adding config.gem 'haml' to my .rb environment, but this also does not work.

, haml .

+3
11

, , haml Rails, , .

  $ cd ..
  $ haml --rails <yourproject>

, haml gem

$ gem install haml

, , haml gem, ubuntu.

!

: "haml -rails" HAML 3.1

+7

, , , index.erb, , index.haml . erb .

, , , , - .

+3

(. ) Rails 2.3.4. gem uninstall/gem install . Rails 2.3.2! ( , HAML Rails).

sudo gem install -v 2.3.2 rails
+2

Rails 3.1, -.

+1

rails 2.3.18, bundler, , , 3.1.3. (4.0).

gem 'haml', '3.1.3'

:)

+1

, .

: http://www.ruby-forum.com/topic/101346 resource_url resource_path > . ?

, resource_url redirect_to , :

htp://localhost: 4000/categories/new.erb /

resource_path, . - , ?

resource_url .erb?

:

ActionView::MissingTemplate (Missing template http://localhost:4000/categories/new.erb in view path app/views):
haml (2.2.2) lib/haml/helpers/action_view_mods.rb:13:in `render'
app/controllers/categories_controller.rb:15:in `create'
haml (2.2.2) rails/./lib/sass/plugin/rails.rb:19:in `process'

P.S. Rails 2.3.3

0

, , index.html.haml_, ...

0

- :

haml .haml

:

test.haml
# not
test.html.haml

5 :

"file.format.haml", , ...

0

, Haml, rails .

0

Ruby 1.9x, Rails 2.3.5 HAML 3.1. , , 1.8 1.9.

, HAML Rails 2, Ruby 1.8. ( , , ). Rails 2 gem.config "haml" .

, Rails 3 Ruby 1.9!

0

I had the same problem.

The solution is documented at https://github.com/haml/haml/issues/672

You need to add

config.after_initialize do 
  require 'haml'
  Haml.init_rails(binding)
end

inside your config / environment.rb in the configuration block Rails::Initializer.run do |config|!

0
source

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


All Articles