2012-04-18 162 views
0

我會盡量在這裏簡短地講一個簡短的故事。我是一個Ubuntu服務器上建設RefineryCMS應用程序,一切工作正常,直到我開始收到以下錯誤消息:Rails URLs not working

.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.12/lib/active_support/dependencies.rb:242:in `require': no such file to load -- devise (LoadError) 

我能夠運行

gem install devise 

其次是解決這個錯誤

bundle install 

bundle update 

這解決了它無法啓動的問題,但沒有一個URL的工作,包括默認的,如/用戶/登錄,隨時隨地我會瀏覽到這樣的頁面我頁面顯示錯誤,如

No route matches [GET] "https://stackoverflow.com/users/login" 

認爲這是我的gemset問題,我創建了一個新的,然後創建一個新的,然後開始新的煉油廠應用程序,目的是將文件移動到它。其啓動然而,當跟進,確保煉油廠工作,我花了到默認軌頁和刪除/public/index.html後,我再次啓動,並得到了同樣的錯誤

No route matches [GET] "https://stackoverflow.com/users/login" 

要仔細檢查煉廠工作我運行了一個簡單的命令行命令來覆蓋/app/views/pages/show.html.erb文件,它工作正常,然後再次啓動並手動輸入到用戶/註冊頁面的URL,並再次獲得相同的路線錯誤。這些都證實了我的路線被解釋的方式存在一些問題,儘管我不知道在哪個層面上。

我在原始應用程序中使用rails 3.0.12,webrick 1.3.1和ruby 1.9.2。

目前,這是我的Gemfile:

source 'http://rubygems.org' 

gem "devise" 
gem "savon" 
gem 'refinerycms-testing' 
gem "factory_girl_rails" 
gem "guard-rspec" 
gem "rspec" 

# gem 'rails', '3.0.0' 

# Bundle edge Rails instead: 
# gem 'rails', :git => 'git://github.com/rails/rails.git' 

gem 'sqlite3', :require => 'sqlite3' 

# Use unicorn as the web server 
# gem 'unicorn' 

# Deploy with Capistrano 
# gem 'capistrano' 

# To use debugger 
# gem 'ruby-debug' 

# Bundle the extra gems: 
# gem 'bj' 
# gem 'nokogiri' 
# gem 'sqlite3-ruby', :require => 'sqlite3' 
# gem 'aws-s3', :require => 'aws/s3' 

# Bundle gems for the local environment. Make sure to 
# put test-only gems in this group so their generators 
# and rake tasks are available in development mode: 
# group :development, :test do 
# gem 'webrat' 
# end 

# REFINERY CMS ================================================================ 
# Anything you put in here will be overridden when the app gets updated. 

#gem 'refinerycms',    '~> 1.0.9' 

=begin #testing 
group :development, :test do 
    # To use refinerycms-testing, uncomment it (if it's commented out) and run 'bundle install' 
    # Then, run 'rails generate refinerycms_testing' which will copy its support files. 
    # Finally, run 'rake' to run the tests. 
    #gem 'refinerycms-testing' 
    gem 'capybara-webkit' 

    if RbConfig::CONFIG['target_os'] =~ /darwin/i 
     gem 'growl' 
    end 

    gem 'spork', '~> 0.9.0.rc', :platforms => :ruby 
    gem 'guard-spork', :platforms => :ruby 
    gem 'guard-rspec', :platforms => :ruby 
    gem 'generator_spec' 
end 

=end #testing 

# END REFINERY CMS ============================================================ 

# USER DEFINED 


    # Specify additional Refinery CMS Engines here (all optional): 
    # gem 'refinerycms-inquiries', '~> 1.0' 
    # gem "refinerycms-news",   '~> 1.2' 
    # gem 'refinerycms-blog',   '~> 1.6' 
    # gem 'refinerycms-page-images', '~> 1.0' 

    # Add i18n support (optional, you can remove this if you really want to). 
    #gem 'refinerycms-i18n',   '~> 1.0.0' 

# END USER DEFINED 

而且我的routes.rb文件看起來像:

Quicksmile::Application.routes.draw do 

    match "/" => redirect("/new-practices") 

    # The priority is based upon order of creation: 
    # first created -> highest priority. 

    # Sample of regular route: 
    # match 'products/:id' => 'catalog#view' 
    # Keep in mind you can assign values other than :controller and :action 

    # Sample of named route: 
    # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase 
    # This route can be invoked with purchase_url(:id => product.id) 

    # Sample resource route (maps HTTP verbs to controller actions automatically): 
    # resources :products 

    # Sample resource route with options: 
    # resources :products do 
    #  member do 
    #  get 'short' 
    #  post 'toggle' 
    #  end 
    # 
    #  collection do 
    #  get 'sold' 
    #  end 
    # end 

    # Sample resource route with sub-resources: 
    # resources :products do 
    #  resources :comments, :sales 
    #  resource :seller 
    # end 

    # Sample resource route with more complex sub-resources 
    # resources :products do 
    #  resources :comments 
    #  resources :sales do 
    #  get 'recent', :on => :collection 
    #  end 
    # end 

    # Sample resource route within a namespace: 
    # namespace :admin do 
    #  # Directs /admin/products/* to Admin::ProductsController 
    #  # (app/controllers/admin/products_controller.rb) 
    #  resources :products 
    # end 

    # You can have the root of your site routed with "root" 
    # just remember to delete public/index.html. 

    # See how all your routes lay out with "rake routes" 

    # This is a legacy wild controller route that's not recommended for RESTful applications. 
    # Note: This route will make all actions in every controller accessible via GET requests. 
    # match ':controller(/:action(/:id(.:format)))' 
end 

爲什麼會造成它終止確認該建煉油廠的路由,無論是原應用程序或新的應用程序是在事後啓動的?有沒有辦法解決它?如果沒有,是否有辦法將事情推回到他們正常工作的地步?

回答

1

它看起來像我可能已經完成了設備設置的一部分,但不是全部。你有兩個發電機嗎?

rails generate devise:install 
rails generate devise User 

routes.rb通常會包含這樣的內容:devise_for :users如果它已正確設置。這就是創建像user/sign_in這樣的所有路線的原因。