Skip to content

Commit

Permalink
Update Lodo to Rails 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel Liljencrantz committed Jun 22, 2010
1 parent 0966be0 commit e29bc68
Show file tree
Hide file tree
Showing 27 changed files with 369 additions and 475 deletions.
35 changes: 35 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
source 'http://rubygems.org'

gem 'rails', '3.0.0.beta3'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'pg'
gem 'bundler'

gem 'json'

gem "machinist"
gem "faker"
gem "devise", "1.1.rc1"
gem "warden"
gem "declarative_authorization", :git => "http://github.com/stffn/declarative_authorization.git"

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri', '1.4.1'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'

# Bundle gems for certain environments:
# gem 'rspec', :group => :test
# group :test do
# gem 'webrat'
# end
11 changes: 2 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require File.expand_path('../config/application', __FILE__)

require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

require 'tasks/rails'

Rake::Task["db:test:prepare"].enhance(['db:test:purge', 'db:schema:load']) do
Rake::Task["db:test:prepare"].reenable
Rake::Task["db:test:purge"].reenable
Rake::Task["db:schema:load"].reenable
end

Rails::Application.load_tasks
3 changes: 0 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ class ApplicationController < ActionController::Base
# Uncomment the :secret if you're not using the cookie session store
# protect_from_forgery # :secret => 'fd4b65ee1595df77234ee4ea6a277542'

filter_parameter_logging "password"

# See ActionController::Base for details
# Uncomment this to filter the contents of submitted sensitive data parameters
# from your application log (in this case, all fields with names like "password").
# filter_parameter_logging :password


protected

def set_locale_now
Expand Down
5 changes: 1 addition & 4 deletions app/views/layouts/admin.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
<%= stylesheet_link_tag 'datepicker' %>
<%= stylesheet_link_tag 'journals' %>
<%= stylesheet_link_tag 'lodo' %>
<%= javascript_include_tag 'jquery' %>
<% Dir.open("#{RAILS_ROOT}/public/javascripts/").reject {|f| File.directory?("#{RAILS_ROOT}/public/javascripts/" + f)}.reject {|f| f.to_s =~ /jquery/ }.reject{|f| f.to_s =~ /^\.+$/}.each do |js| -%>
<script src="/javascripts/<%= js.to_s -%><%= ActionController::Base.perform_caching ? "" : "?#{(rand() * 10000000000000000).to_i}" -%>" type="text/javascript"></script>
<% end %>
<%= javascript_include_tag :all %>
</head>
<body>
<div class='main_menu'>
Expand Down
6 changes: 1 addition & 5 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@
<%= stylesheet_link_tag 'datepicker' %>
<%= stylesheet_link_tag 'journals' %>
<%= stylesheet_link_tag 'lodo' %>
<%= javascript_include_tag 'jquery' %>
<% Dir.open("#{RAILS_ROOT}/public/javascripts/").reject {|f| File.directory?("#{RAILS_ROOT}/public/javascripts/" + f)}.reject {|f| f.to_s =~ /jquery/ }.reject{|f| f.to_s =~ /^\.+$/}.each do |js| -%>
<script src="/javascripts/<%= js.to_s -%><%= ActionController::Base.perform_caching ? "" : "?#{(rand() * 10000000000000000).to_i}" -%>" type="text/javascript"></script>
<% end %>
<%= javascript_include_tag :all %>
</head>
<body>
<% if user_signed_in? %>

<div class='main_menu'>
<ul>
<li><%= link_to t(:chart_of_accounts, :scope => :layout), accounts_path %></li>
Expand Down
4 changes: 4 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Lodo::Application
76 changes: 76 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
require File.expand_path('../boot', __FILE__)

require 'rails/all'

# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)

module Lodo
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{config.root}/extras )

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# Configure generators values. Many other options are available, be sure to check the documentation.
# config.generators do |g|
# g.orm :active_record
# g.template_engine :erb
# g.test_framework :test_unit, :fixture => true
# end

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]

config.time_zone = 'UTC'

# The internationalization framework can be changed to have another default locale (standard is :en) or more load paths.
# All files from config/locales/*.rb,yml are added automatically.
# config.i18n.load_path << Dir[File.join(RAILS_ROOT, 'my', 'locales', '*.{rb,yml}')]
# config.i18n.default_locale = :de
config.i18n.default_locale = :nb

# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
config.action_dispatch.session = {
:session_key => '_lodo3_session',
:secret => '29e52c8e64c464b41e52b98c9cceb4e43d1d8870df42124cd96be3c4004179720c0326431b0126f1f27d9c65bd834d1028c8f745ddcc8484e32ff0ac3e7d75fa'
}

end
end



ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "mail.freecodeint.com",
:port => 25,
# :domain => "freecode.no",
# :user_name => "[email protected]",
# :password => "MyPassword",
:authentication => :plain
}
113 changes: 5 additions & 108 deletions config/boot.rb
Original file line number Diff line number Diff line change
@@ -1,109 +1,6 @@
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb

RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)

module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end

def booted?
defined? Rails::Initializer
end

def pick_boot
(vendor_rails? ? VendorBoot : GemBoot).new
end

def vendor_rails?
File.exist?("#{RAILS_ROOT}/vendor/rails")
end

def preinitialize
load(preinitializer_path) if File.exist?(preinitializer_path)
end

def preinitializer_path
"#{RAILS_ROOT}/config/preinitializer.rb"
end
end

class Boot
def run
load_initializer
Rails::Initializer.run(:set_load_path)
end
end

class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
end
end

class GemBoot < Boot
def load_initializer
self.class.load_rubygems
load_rails_gem
require 'initializer'
end

def load_rails_gem
if version = self.class.gem_version
gem 'rails', version
else
gem 'rails'
end
rescue Gem::LoadError => load_error
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
exit 1
end

class << self
def rubygems_version
Gem::RubyGemsVersion rescue nil
end

def gem_version
if defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION
elsif ENV.include?('RAILS_GEM_VERSION')
ENV['RAILS_GEM_VERSION']
else
parse_gem_version(read_environment_rb)
end
end

def load_rubygems
require 'rubygems'
min_version = '1.3.1'
unless rubygems_version >= min_version
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
end

rescue LoadError
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1
end

def parse_gem_version(text)
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
end

private
def read_environment_rb
File.read("#{RAILS_ROOT}/config/environment.rb")
end
end
end
require 'rubygems'
# Set up gems listed in the Gemfile.
if File.exist?(File.expand_path('../../Gemfile', __FILE__))
require 'bundler'
Bundler.setup
end

# All that for this:
Rails.boot!
22 changes: 17 additions & 5 deletions config/database.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql
adapter: postgresql
encoding: utf8
database: lodo
database: lodo_dev
pool: 5

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
encoding: utf8
database: lodo_test
pool: 5

production:
adapter: postgresql
encoding: utf8
database: lodo_prod
pool: 5
username: root
password: SOMETHINGYOUWANNAKNOW
host: localhost
Loading

0 comments on commit e29bc68

Please sign in to comment.