Skip to content

Commit

Permalink
Generate root method
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Aug 5, 2011
1 parent aada8dc commit e9ab5f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/cramp/generators/templates/application/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
module <%= app_const_base %>
class Application
def self.root(path = nil)
@_root ||= File.expand_path(File.dirname(__FILE__))
path ? File.join(@_root, path.to_s) : @_root
end
def self.env
@_env ||= ENV['RACK_ENV'] || 'development'
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cramp/generators/templates/application/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if <%= app_const %>.env == 'development'
use Rack::Reloader, 0

# Serve assets from /public
use Rack::Static, :urls => ["/javascripts"], :root => File.expand_path("./public", __FILE__)
use Rack::Static, :urls => ["/javascripts"], :root => <%= app_const %>.root(:public)
end

# Running thin :
Expand Down

0 comments on commit e9ab5f8

Please sign in to comment.