0
votes

When I attempt to run rake assets:precompile I am having a weird issue that appears to be related to my database.yml. However, accessing the website directly works fine (if i change the environment to fall back on the asset pipeline).

Rails 3.2.12, ruby 1.9.3p385, Windows Server 2008.

My database.yml file (host, username, and password removed):

production:
  adapter: mysql2
  encoding: utf8
  reconnect: true
  database: images
  pool: 5
  username: username
  password: password
  host: host

A snippet of the top portion of the error:

D:\inetpub\wwwroot\images>rake assets:precompile
C:/Ruby19/bin/ruby.exe C:/Ruby19/bin/rake assets:precompile:all RAILS_ENV=assets:precompile RAILS_GROUPS=assets
rake aborted!
undefined method `sub' for nil:NilClass
D:/inetpub/wwwroot/images/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_specification.rb:68:in `co
nnection_url_to_hash'
D:/inetpub/wwwroot/images/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_specification.rb:36:in `bl
ock in resolve_string_connection'
D:/inetpub/wwwroot/images/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_specification.rb:35:in `fe
tch'

Edit:

Here is the contents of connection_specification.rb, it bombs out on this line: :database => config.path.sub(%r{^/},""),:

       def connection_url_to_hash(url) # :nodoc:
          config = URI.parse url
          adapter = config.scheme
          adapter = "postgresql" if adapter == "postgres"
          spec = { :adapter  => adapter,
                   :username => config.user,
                   :password => config.password,
                   :port     => config.port,
                   :database => config.path.sub(%r{^/},""),
                   :host     => config.host }
          spec.reject!{ |_,value| value.blank? }
          spec.map { |key,value| spec[key] = URI.unescape(value) if value.is_a?(String) }
          if config.query
            options = Hash[config.query.split("&").map{ |pair| pair.split("=") }].symbolize_keys
            spec.merge!(options)
          end
          spec
        end
      end
    end
1

1 Answers

1
votes

Your output generates this: RAILS_ENV=assets:precompile

however I do not think you've declared an assets environment.

try $:. rake assets:precompile RAILS_ENV='production' RAILS_GROUPS='assets'

PS: windows is.. let's say undeveloped when it comes to rails support so you may want to think about switching to another OS. My personal favorite is Debian sqeeze