Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8568065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:01:24+00:00 2026-06-11T18:01:24+00:00

I am trying to create a modular sinatra application and need each of my

  • 0

I am trying to create a modular sinatra application and need each of my sub-applications to look for the views directory at the root of my project’s folder. But it only looks up the views directory in the sub-directory itself instead of the root. Here’s what my project looks like:

├── config.ru
├── music_catalog
│   └── app.rb
├── public
│   ├── css
│   │   └── site.css
│   └── images
│       ├── content_top_bg.jpg
│       ├── demo_image_01.jpg
│       ├── god_save_http_it_aint_no_human_being.png
│       ├── header_bg.jpg
│       ├── home-showcase.png
│       ├── hover_link_bg.jpg
│       ├── its_little_its_blue_and_its_magical.jpeg
│       ├── linkbar_bg.jpg
│       ├── logo.png
│       ├── main_graphics.jpg
│       ├── placeholder.gif
│       ├── placeholder.jpg
│       ├── placeholder.png
│       ├── right_navbar_bg.jpg
│       └── shadow_left.jpg
└── views
    ├── album.haml
    ├── genre.haml
    ├── index.haml
    ├── layout.haml
    ├── login.haml
    └── not_found.haml

So in my config.ru I try doing this:

require 'sinatra'

require './music_catalog/app.rb'

set :root, File.dirname(__FILE__)


# enable :run

map "/" do
   run MusicCatalog
end

In app.rb inside of music_catalog I use the root variable like so:

require 'sinatra/base'

`# I thing I am doing this wrong`

set :views, Proc.new { File.join(root, "sites/#{site}/views") }

class MusicCatalog < Sinatra::Base
   get "/" do
      haml :index
   end
end

But instead of pulling out my index.haml out of my root directory, it errors out like so:

Errno::ENOENT at /
No such file or directory - /Users/amiterandole/Dropbox/code/rsandbox/sinatra_music_store/music_catalog/views/index.haml

I am using ruby 1.9.3p194

Please help me set the views directory to the proper location in the root views folder.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:01:25+00:00Added an answer on June 11, 2026 at 6:01 pm

    Ok I figured it out. The set :views statement should actually be inside my app class like this:

    class MusicCatalog < Sinatra::Base
    
      **set :views, Proc.new { File.join(root, "../views") }**
    
      get "/" do
        haml :index
      end
    end
    

    Also I was joining the root in the wrong way earlier. Fixed that. Now sinatra is correctly loading my templates

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a modular application in javascript using pusher. Different modules need
I am trying to create a modular Silverlight 4.0 application, where the modules are
I am trying to create a Modular structure to zend framework project, what i
I am trying to create a modular html document that employs smooth scrolling. If
I'm trying create a RCP Application with Eclipse, but I can't get past the
I'm trying create a scaling layout for an Android application. The whole screen should
I am trying to make a modular application in delphi2010 using BPL. Problem is
I am trying create a small web application that allows a user to login
I'm trying to develop an application with a very modular approach to commands and
I am trying to create a modular structure that will eventually live inside another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.