Skip to content

Commit

Permalink
Fixed ability to run as Rails Engine or Application.
Browse files Browse the repository at this point in the history
  • Loading branch information
ndbroadbent committed Mar 10, 2012
1 parent 6deedfc commit 52beb0b
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 17 deletions.
3 changes: 2 additions & 1 deletion app/models/setting.rb
Expand Up @@ -114,8 +114,9 @@ def database_and_table_exists?
# Loads settings from YAML files
def load_settings_from_yaml
@@yaml_settings = {}.with_indifferent_access

setting_files = [
Rails.root.join("config", "settings.default.yml"),
FatFreeCRM.root.join("config", "settings.default.yml"),
Rails.root.join("config", "settings.yml")
]

Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_tabbed.html.haml
Expand Up @@ -5,7 +5,7 @@
= link_to(tab[:url], :class => tab[:active] ? "active" : "") do
- unless request.fullpath.include?("/admin")
- img_base_path = "tab_icons/#{tab[:text].to_s.downcase.sub(/^tab_/, '')}"
- if File.exists?(Rails.root.join("vendor/assets/images/#{img_base_path}.png"))
- if Rails.application.assets.find_asset("#{img_base_path}.png")
= image_tag("#{img_base_path}#{tab[:active] ? "_active" : ""}.png")
= t(tab[:text])

Expand Down
9 changes: 3 additions & 6 deletions config.ru
@@ -1,7 +1,4 @@
require 'rubygems'
require 'bundler'
# This file is used by Rack-based servers to start the application.

Bundler.require :default, :development

Combustion.initialize!
run Combustion::Application
require ::File.expand_path('../config/environment', __FILE__)
run FatFreeCRM::Application
4 changes: 1 addition & 3 deletions config/application.rb
@@ -1,9 +1,7 @@
require File.expand_path('../boot', __FILE__)

# Use the Syck YAML parser
require 'fat_free_crm/syck_yaml'

require 'rails/all'
require 'fat_free_crm/syck_yaml'

if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Expand Down
37 changes: 37 additions & 0 deletions config/environments/development.rb
@@ -0,0 +1,37 @@
FatFreeCRM::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true

# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log

# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin

# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict

# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5

# Do not compress assets
config.assets.compress = false

# Expands the lines which load the assets
config.assets.debug = true
end
2 changes: 1 addition & 1 deletion fat_free_crm.gemspec
Expand Up @@ -36,7 +36,7 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'spork'
gem.add_development_dependency 'database_cleaner'
gem.add_development_dependency 'fuubar'
gem.add_development_dependency 'factory_girl', '~> 2.6.0'
gem.add_development_dependency 'factory_girl', '~> 2.6.1'
end


12 changes: 12 additions & 0 deletions lib/fat_free_crm.rb
Expand Up @@ -15,6 +15,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#------------------------------------------------------------------------------

# Use the Syck YAML parser
require 'fat_free_crm/syck_yaml'

require "fat_free_crm/gem_dependencies"
require "fat_free_crm/gem_ext"
require "fat_free_crm/plugin_dependencies"
Expand All @@ -38,3 +41,12 @@
require "fat_free_crm/callback"
require "fat_free_crm/dropbox" if defined?(::Rake)
require "fat_free_crm/plugin"


module FatFreeCRM
# Return the root path of either the Application or the Engine,
# depending on how Fat Free CRM is loaded
def self.root
(defined?(Application) ? Application : Engine).root
end
end
8 changes: 3 additions & 5 deletions script/rails
@@ -1,8 +1,6 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/fat_free_crm/engine', __FILE__)

require 'rails/all'
require 'rails/engine/commands'
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'

0 comments on commit 52beb0b

Please sign in to comment.