0

(Rails 3.1、Heroku cedar、ruby 1.9.3、macosx、eclipse、git)

我的应用程序部署在 heroku cedar 上,并且设计登录层在上一个版本中运行良好,但 users-path 现在会抛出缺少模板的错误。它在我的开发机器上运行良好。

我对最新所做的两个重大更改是 - 1) 从 Devise 生成用户模型/视图/控制器,以便我可以自定义。2) 为设计用户路径添加路径前缀(即注册)

作为对 Heroku 的测试,将 root_path 更改为不同的控制器/索引(即 messages_path),它允许访问应用程序。一切正常,除了单击主页链接,它再次尝试转到 users_path (同样缺少模板错误):

<%= link_to image_tag("homeIcon.png"), users_path, :method =>"GET", :id =>"menulink", :title => "Go Home." %>

我迫切希望对这个问题有任何深入的了解,因为除了不在 Heroku 上以这种方式使用 Devise 和 Users 之外,我不知道该怎么做。非常感谢任何和所有想法!

谢谢,安妮

(研究注意:在错误消息上搜索;类似的问题,但没有关于未能转到 users#index 的 root_path,与设计和用户自定义无关导致错误消息;stackoverflow 引擎提出的审查问题列表)

在ecipe中登录输出本地开发:

Started GET "/" for 127.0.0.1 
(0.2ms)  SHOW search_path
Processing by UsersController#index as HTML
Redirected to [local-machine]/myprefix/users/sign_in
...
Started GET "/" for 127.0.0.1 at 2014-05-17 08:31:13 -0400
Processing by UsersController#index as HTML
User Load (0.3ms)  SELECT "users".* FROM "users"

Heroku 上的登录输出。用户登录,但 users/index.html 页面导致“抱歉,但出现问题”页面。

Started GET "/myprefix/users/sign_in" for ...
heroku[router]: at=info method=GET path=/assets/application...dyno=web.1
Rendered devise/sessions/new.html.erb within layouts/application (53.2ms)
Processing by Devise::SessionsController#new as HTML
cache: [GET /myprefix/users/sign_in] miss
…
heroku[router]: at=info method=POST path=/myprefix/users/sign_in
host=myapp.herokuapp.com                            
…
Started POST "/myprefix/users/sign_in" 
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓"... 
Redirected to http://myapp.herokuapp.com/
cache: [POST /myprefix/users/sign_in] invalidate, pass
method=GET path=/ host=myapp.herokuapp.com request_id=f...
Processing by UsersController#index as HTML
Completed 500 Internal Server Error in 49ms
Started GET "/" for ...
ActionView::MissingTemplate (Missing template users/index, application/index 
with {:handlers=>[:erb, :builder, :coffee], :formats=>[:html], :locale=>[:en, :en]}.
Searched in:
 ActionView::MissingTemplate (Missing template users/index, application/index with 
 {:handlers=>[:erb, :builder, :coffee], :formats=>[:html], :locale=>[:en, :en]}.
Searched in:
* "/app/app/views"
* "/app/vendor/bundle/ruby/1.9.1/gems/devise-2.2.8/app/views"
):
cache: [GET /] miss
(no other output)

File.properties shows location (i.e. eclipse ide)
[path-to-my-rail-app]/app/views/users/index.html.erb
[path-to-my-rail-app]/app/views/layouts/application.html.erb

routes.rb
MyApp::Application.routes.do
devise_for :views
devise_for :admins
devise_for :users, :path_prefix => 'myprefix'
resources :users do
    resources :x, only: [:new, :create, :index, :edit,:destroy]
    resources :y, only: [:new, :create, :index, :update, :destroy]
    resources :z, only: [:new, :create, :index, :edit,:destroy,:update] do
       get :q, :on => :member
    end
end

rake routes output:

new_user_session GET    
       /myprefix/users/sign_in(.:format) 
       {:action=>"new", :controller=>"devise/sessions"}
user_session POST   
       /myprefix/users/sign_in(.:format)   
       {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session DELETE 
       /myprefix/users/sign_out(.:format) 
       {:action=>"destroy", :controller=>"devise/sessions"}
user_password POST   
       /myprefix/users/password(.:format) 
       {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET    
       /myprefix/users/password/new(.:format)    
       {:action=>"new", :controller=>"devise/passwords"}
edit_user_password 
   GET    
      /myprefix/users/password/edit(.:format)  
       {:action=>"edit", :controller=>"devise/passwords"}
   PUT    /myprefix/users/password(.:format)                 
       {:action=>"update", :controller=>"devise/passwords"}
cancel_user_registration 
   GET    /myprefix/users/cancel(.:format)
       {:action=>"cancel", :controller=>"devise/registrations"}
user_registration POST   /myprefix/users(.:format)  
        {:action=>"create", :controller=>"devise/registrations"}
new_user_registration GET    
       /myprefix/users/sign_up(.:format) 
        {:action=>"new", :controller=>"devise/registrations"}
edit_user_registration GET
      /myprefix/users/edit(.:format)
        {:action=>"edit", :controller=>"devise/registrations"}
     PUT    /myprefix/users(.:format)
        {:action=>"update", :controller=>"devise/registrations"}
     DELETE /myprefix/users(.:format)
        {:action=>"destroy", :controller=>"devise/registrations"}

users GET    /users(.:format) {:action=>"index",    :controller=>"users"}
      POST   /users(.:format) {:action=>"create", :controller=>"users"}
new_user GET    /users/new(.:format)                           
         {:action=>"new", :controller=>"users"}
edit_user GET    /users/:id/edit(.:format)                      
         {:action=>"edit", :controller=>"users"}
user GET    /users/:id(.:format)                           
         {:action=>"show", :controller=>"users"}
    PUT    /users/:id(.:format)                           
         {:action=>"update", :controller=>"users"}
    DELETE /users/:id(.:format)                           
         {:action=>"destroy", :controller=>"users"}
root        /                                              
         {:controller=>"users", :action=>"index"}

gemfile: source ' http://rubygems.org ' gem 'bundler' ruby​​ "1.9.2" gem 'rails', '3.1.3' gem 'rails_12factor', group: :production gem 'pg' gem 'devise'

users_controller.rb:

class UsersController < ApplicationController
  def index
    @users = User.active_users   
  end
end

应用程序.rb

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

require 'rails/all'
require 'devise'
4

2 回答 2

0

显然您的应用程序找不到该users/index.html.erb文件。

您能否确认该文件存在,并且它也已被推送到生产环境中?

于 2014-05-17T17:24:29.233 回答
0

好吧,它是固定的,但以最奇怪的方式。感谢 stackexchange 的所有帖子,这些帖子给了我更多的见解,也感谢 Raul 推动了验证的想法。

对于其他陷入云地狱的人来说,这是它的要点。

1 - 视图/用户需要是视图/用户。不知何故,我的本地环境创建了 *U*sers。整个 /user 位置似乎被推送到heroku,但显然不是。

2 - (在 Raul 的问题之后,一个小时试图找到 heroku 目录结构)对 /users/index.html 做了一个简单的错字更改,看看我尝试提交它时是否有错误。在提交期间(eclipse git 窗口),我注意到项目资源管理器中的文件名一直在“用户/”和“用户”之间滑动。

一旦 git commit 完成,我又做了一个 heroku push master,问题就解决了。我现在登陆 /users/index.html

感谢大家的拯救,我喜欢这个网站。

安妮

于 2014-05-18T02:23:03.350 回答