Second (last) part of multiple foodcoop installation.

* When before_filter select_foodcoop is activated,
  the database and configs will be loaded on each request.
* Replaced APP_CONFIG with new Foodsoft.config method.
This commit is contained in:
Benjamin Meichsner 2009-03-24 17:25:33 +01:00
parent 1c24127928
commit ffc3adf907
18 changed files with 51 additions and 57 deletions

View file

@ -1,7 +1,7 @@
class ApplicationController < ActionController::Base
# If you wanna run multiple foodcoops on one installation uncomment next line.
before_filter :select_foodcoop
#before_filter :select_foodcoop
before_filter :authenticate, :store_controller
after_filter :remove_controller
@ -17,7 +17,7 @@ class ApplicationController < ActionController::Base
# Use this method to call a rake task,,
# e.g. to deliver mails after there are created.
def call_rake(task, options = {})
options[:rails_env] ||= Rails.env
options[:rails_env] ||= Foodsoft.env
args = options.map { |n, v| "#{n.to_s.upcase}='#{v}'" }
system "/usr/bin/rake #{task} #{args.join(' ')} --trace 2>&1 >> #{Rails.root}/log/rake.log &"
end
@ -60,14 +60,6 @@ class ApplicationController < ActionController::Base
private
# selects the foodcoop depending on the subdomain
# def select_foodcoop
# # get subdomain and set FoodSoft-class-variable (for later config-requests)
# FoodSoft.subdomain = request.subdomains.first
# # set database-connection
# ActiveRecord::Base.establish_connection(FoodSoft.get_database)
# end
# Ensures the HTTP content-type encoding is set to "UTF-8" for "text/html" contents.
def ensureUTF8
content_type = headers["Content-Type"] || "text/html"
@ -159,7 +151,7 @@ class ApplicationController < ActionController::Base
# Get subdomain
subdomain = request.subdomains.first
# Set Config
Foodsoft.set_env subdomain
Foodsoft.env = subdomain
# Set database-connection
ActiveRecord::Base.establish_connection(Foodsoft.database(subdomain))
end

View file

@ -127,13 +127,13 @@ class OrdersController < ApplicationController
def text_fax_template
order = Order.find(params[:id])
supplier = order.supplier
contact = APP_CONFIG[:contact].symbolize_keys
text = "Bestellung für" + " #{APP_CONFIG[:name]}"
contact = Foodsoft.config[:contact].symbolize_keys
text = "Bestellung für" + " #{Foodsoft.config[:name]}"
text += "\n" + "Kundennummer" + ": #{supplier.customer_number}" unless supplier.customer_number.blank?
text += "\n" + "Liefertag" + ": "
text += "\n\n#{supplier.name}\n#{supplier.address}\nFAX: #{supplier.fax}\n\n"
text += "****** " + "Versandadresse" + "\n\n"
text += "#{APP_CONFIG[:name]}\n#{contact[:street]}\n#{contact[:zip_code]} #{contact[:city]}\n\n"
text += "#{Foodsoft.config[:name]}\n#{contact[:street]}\n#{contact[:zip_code]} #{contact[:city]}\n\n"
text += "****** " + "Artikel" + "\n\n"
text += "Nummer" + " " + "Menge" + " " + "Name" + "\n"
# now display all ordered articles