2014-02-25 79 views
-2

我在一個項目上工作,在安裝Ruby on Rails(ruby 2.0.0和rails 4.0.0)之後,我把我的項目的源碼和當我嘗試啓動我的rails服務器我有這樣的錯誤:Rails服務器意外':'

C:\Users\alex\Desktop\Appli>rails server 
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:76: in `require': C:/Users/alex/Desktop/Appli/config/application.rb:38: syntax error , unexpected ':', expecting end-of-input (SyntaxError) 
     from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>' 
     from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap' 
     from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>' 
     from bin/rails:4:in `require' 
     from bin/rails:4:in `<main>' 

application.rb中:

 require File.expand_path('../boot', __FILE__) 

    require 'rails/all' 

    # Require the gems listed in Gemfile, including any gems 
    # you've limited to :test, :development, or :production. 
    Bundler.require(:default, Rails.env) 

    module Project 
    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. 

    # 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 
    end 
end 

    # Set up gems listed in the Gemfile. 
    ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 

    require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) 
    # MySQL. Versions 4.1 and 5.0 are recommended. 
    # 
    # Install the MYSQL driver 
    # gem install mysql2 
    # 
    # Ensure the MySQL gem is defined in your Gemfile 
    # gem 'mysql2' 
    # 
    # And be sure to use new-style password hashing: 
    # http://dev.mysql.com/doc/refman/5.0/en/old-client.html 
    development:             << line 38 
     adapter: mysql2 
     encoding: utf8 
     database: project_development 
     pool: 5 
     username: root 
     password: root 
     socket: /var/run/mysqld/mysqld.sock 

有人已經看到這個錯誤?

謝謝。

+4

您是否考慮過包含C:/Users/alex/Desktop/Appli/config/application.rb的第38行?如果你不打算向我們展示任何代碼,唯一的幫助就是你有一個意想不到的':'如38。 – meagar

+1

或者更好的是,看看你自己的'application.rb'的第38行,然後看看是否有任何流浪冒號或其他無效的語法。 –

+0

爲什麼不分享你的'application.rb' – HackerKarma

回答

1

首先,這是數據庫的配置,應駐留在database.yml而不是application.rb中

development: 
    adapter: mysql2 
    encoding: utf8 
    database: project_development 
    pool: 5 
    username: root 
    password: root 
    socket: /var/run/mysqld/mysqld.sock 

其次,避免給4個空間,只給2,這就是該公約。在上面的數據庫配置中,我遵循了2個選項卡空間約定。

+0

同意,問題在於你出於某種原因複製了application.rb中的一大塊database.yml。標籤大小不是問題:) –

+0

是的,僅僅是爲了約定。 – RSB