Vishal
Vishal

Reputation: 113

Application.html.haml file not rendered

I am new to ROR .I am working on a project which was using erb files and I have now converted them in haml.

I have installed haml gem as mentioned in other posts but no luck! and using rails 4.

The problem is this application.haml file is not rendered I don't know why . Please help please let me know if any other info required here is application.html.haml

!!!
%html
  %head
    %title PipeCast
    %link{:rel => "stylesheet", :href => "assets/stylesheets/application.css"}
    = csrf_meta_tags
    = render 'layouts/shim'
  %body
    = render 'layouts/header'
    = yield

here is application_controller.rb

class ApplicationController < ActionController::Base

  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  # protect_from_forgery with: :null_session

  # before_filter :set_cache_buster
#
  # def set_cache_buster
    # response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
    # response.headers["Pragma"] = "no-cache"
    # response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
  # end
#
end

this is pages controller extending application controller but its not rendering application layout

class PagesController < ApplicationController
  def home 

     @greeting = "Hello Welcome to Ruby Web Application"
  end
end

Server logs You can notice here although all files are haml but it is rendering pages/home.html.erb dont know from where !

=> Rails 4.1.1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
[2014-11-23 01:13:29] INFO  WEBrick 1.3.1
[2014-11-23 01:13:29] INFO  ruby 2.1.0 (2013-12-25) [x86_64-darwin14.0]
[2014-11-23 01:13:29] INFO  WEBrick::HTTPServer#start: pid=20082 port=3000


Started GET "/" for 127.0.0.1 at 2014-11-23 01:35:39 +0530
Processing by PagesController#home as HTML
  Rendered pages/home.html.erb (15.2ms)
Completed 200 OK in 79ms (Views: 53.9ms | ActiveRecord: 0.0ms)


Started GET "/" for 127.0.0.1 at 2014-11-23 01:36:27 +0530
Processing by PagesController#home as HTML
  Rendered pages/home.html.erb (0.1ms)
Completed 200 OK in 3ms (Views: 2.9ms | ActiveRecord: 0.0ms)


Started GET "/" for 127.0.0.1 at 2014-11-23 01:36:27 +0530
Processing by PagesController#home as HTML
  Rendered pages/home.html.erb (0.1ms)
Completed 200 OK in 2ms (Views: 1.9ms | ActiveRecord: 0.0ms)


Started GET "/" for 127.0.0.1 at 2014-11-23 01:36:28 +0530
Processing by PagesController#home as HTML
  Rendered pages/home.html.erb (0.1ms)
Completed 200 OK in 2ms (Views: 1.6ms | ActiveRecord: 0.0ms)

Upvotes: 1

Views: 1419

Answers (1)

Stanislav Mekhonoshin
Stanislav Mekhonoshin

Reputation: 4386

Actually you need not layouts, but simple partials.

= render 'layouts/header'

When you use such construction, you are trying to render partial inside layout.

Make sure, that its name is 'app/views/layouts/_header.html.haml'

By conventions partials should begin from underscore character.

Upvotes: 1

Related Questions