(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'