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 8613861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:58:58+00:00 2026-06-12T04:58:58+00:00

I tried to set up a config file for my sinatra app, and simple

  • 0

I tried to set up a config file for my sinatra app, and simple settings work. (the puts in my code prints “Hello!!”) But I read this document, which says I can define settings per environment. I tried it but it doesn’t work. What am I doing wrong? 😉
I’m using this code:

#settings.yml
#environments: :production, :development
environment: :development

bla: Hello!!

development:
  db_adapter:   "sqlite3"
  db_location:  "db/development"
  db_logfile:   $stdout
  db_loglevel:  :debug
  haml: "format => :html5, :ugly => true"

production:
  db_adapter:   "sqlite3"
  db_location:  "db/production"
  db_logfile:   "log/production_db.log"
  db_loglevel:  :error

and

#main.rb
#!/usr/bin/ruby

require 'rubygems'
require 'sinatra'             #Webframework
require 'sinatra/config_file' #Config

set :environment, :development
config_file("settings.yml")

puts settings.bla

DataMapper::Logger.new(settings.db_logfile, settings.db_loglevel)
DataMapper.setup(:default, "#{settings.db_adapter}://#{Dir.pwd}/#{settings.db_location}")
...

It raises a noMethodError for settings.db_logfile…
sorry for my bad english 😉

EDIT1:
I got it 😉
I have to write this into my main.rb:

set :environment, :development

configure :development do
  set :db_adapter     ,  "sqlite3"
  set :db_location    ,  "db/development"
  set :db_logfile     ,  $stdout
  set :db_loglevel    ,  :debug
  set :haml           ,  :format => :html5
end
  • 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-12T04:58:59+00:00Added an answer on June 12, 2026 at 4:58 am

    You want to configure your environments like this:

    configure :production do
      set :db_adapter, "sqlite3"
      set :db_location, "db/production"
      set :db_logfile, "log/production_db.log"
      set :db_loglevel, :error
    end
    
    configure :development do
      set :db_adapter, "sqlite3"
      set :db_location, "db/development"
      set :db_logfile, $stdout
      set :db_loglevel, :debug
      set :haml, {:format => :html5, :ugly => true}
    end
    
    configure :test do
      ...
    end
    

    see Sinatra Readme

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

Sidebar

Related Questions

In my app as part of my settings I set :public, Proc.new { File.join(root,
i am facing one problem. i want to save settings in app.config file i
I've tried to set the executionTimeout in the web.config file: <compilation debug=false targetFramework=4.5> <httpRuntime
I tried to set up my togglebutton properties layout using style.xml. Here's my code:
I've tried to set the margin and border to 0,but still not working. <style
How to overwrite existing log file ??? I have tried to set attribute property
I've written a simple FTP based file synchronization program. The settings of which can
when I set parameter FileLogPath in my quickfix config file (with value: outgoing) and
I am trying to set a system property in tomcat config file so it
I tried to set the tick style to tsManual, the min and max position

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.