我的网站正在我的开发机器上运行,部署到 heroku 我在日志中得到了这个:
2013-01-11T19:29:38+00:00 app[web.1]: Started GET "/hints" for 206.255.88.68 at 2013-01-11 19:29:38 +0000
2013-01-11T19:29:38+00:00 heroku[nginx]: 206.255.88.68 - - [11/Jan/2013:19:29:38 +0000] "GET /hints HTTP/1.1" 500 643 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20100101 Firefox/17.0" baconlanguagetomato.com
2013-01-11T19:29:38+00:00 heroku[router]: at=info method=GET path=/hints host=baconlanguagetomato.com fwd=206.255.88.68 dyno=web.1 queue=0 wait=0ms connect=1ms service=26ms status=500 bytes=643
2013-01-11T19:29:38+00:00 app[web.1]:
2013-01-11T19:29:38+00:00 app[web.1]: ActionView::MissingTemplate (Missing template hints/index, application/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
2013-01-11T19:29:38+00:00 app[web.1]: * "/app/app/views"
2013-01-11T19:29:38+00:00 app[web.1]: * "/app/vendor/bundle/ruby/1.9.1/gems/devise-2.2.0/app/views"
2013-01-11T19:29:38+00:00 app[web.1]: * "/app/vendor/bundle/ruby/1.9.1/gems/kaminari-0.14.1/app/views"
2013-01-11T19:29:38+00:00 app[web.1]: ):
2013-01-11T19:29:38+00:00 app[web.1]: app/controllers/hints_controller.rb:34:in `index'
2013-01-11T19:29:38+00:00 app[web.1]:
2013-01-11T19:29:38+00:00 app[web.1]:
这是我的路线文件的一部分:
resources :hints do
collection do
get 'found_sentences'
end
end
这是我的hints_controller.rb:
#encoding: utf-8
class HintsController < ApplicationController
# GET /hints
# GET /hints.json
authorize_resource
before_filter :authenticate_user!
layout "application", :except => [:found_sentences]
# GET /hints/find_sentences/
def found_sentences
#authorize! :find_sentences, @user, :message => 'Not authorized as an administrator.'
@hints = Hint.where("sentence LIKE ? AND user_id =?", "%#{params[:word]}%", current_user.id) #.order("LENGTH(sentence) ASC").limit(5)
render :layout => 'layouts/found_sentences'
#respond_to do |format|
# format.html # find_sentences.html.erb
# format.json { render json: @hints }
#end
end
def index
#authorize! :index, @user, :message => 'Not authorized as an administrator.'
#@hints = Hint.order(:created_at).reverse()
@hints = Hint.find_all_by_user_id(current_user.id).reverse()
#@hints = @current_user.hints
respond_to do |format|
format.html # index.html.erb
format.json { render json: @hints }
end
end
# GET /hints/1
# GET /hints/1.json
def show
#authorize! :show, @user, :message => 'Not authorized as an administrator.'
@hint = Hint.find(params[:id])
#@hint = @current_user.hints.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @hint }
end
end
# GET /hints/new
# GET /hints/new.json
def new
#authorize! :new, @user, :message => 'Not authorized as an administrator.'
#@hint = Hint.new
@hint = Hint.new(:user_id => @current_user_id)
respond_to do |format|
format.html # new.html.erb
format.json { render json: @hint }
end
end
# GET /hints/1/edit
def edit
#authorize! :edit, @user, :message => 'Not authorized as an administrator.'
@hint = Hint.find(params[:id])
#@hint = Hint.find(:user_id => @current_user_id)
#todo shouldn't be able to edit other user's hints. for some reason the Lesson model responds to @current_user.lessons, but the Hint model doesn't respond to @current_user.hints
end
# POST /hints
# POST /hints.json
def create
#authorize! :create, @user, :message => 'Not authorized as an administrator.'
@hint = Hint.new(params[:hint])
respond_to do |format|
if @hint.save
format.html { redirect_to @hint, notice: 'Hint was successfully created.' }
format.json { render json: @hint, status: :created, location: @hint }
else
format.html { render action: "new" }
format.json { render json: @hint.errors, status: :unprocessable_entity }
end
end
end
# PUT /hints/1
# PUT /hints/1.json
def update
#authorize! :update, @user, :message => 'Not authorized as an administrator.'
@hint = Hint.find(params[:id])
respond_to do |format|
if @hint.update_attributes(params[:hint])
format.html { redirect_to @hint, notice: 'Hint was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @hint.errors, status: :unprocessable_entity }
end
end
end
# DELETE /hints/1
# DELETE /hints/1.json
def destroy
#authorize! :destroy, @user, :message => 'Not authorized as an administrator.'
@hint = Hint.find(params[:id])
@hint.destroy
respond_to do |format|
format.html { redirect_to hints_url }
format.json { head :no_content }
end
end
end
我尝试删除这一行:render :layout => 'layouts/found_sentences'
并取消注释:
#respond_to do |format|
# format.html # find_sentences.html.erb
# format.json { render json: @hints }
#end
但这没有用。接下来我应该尝试什么?
要求更新:
[~/rails_projects/blt]$ls app/views/{application,hints}
ls: app/views/application: No such file or directory
app/views/hints:
_form.html.erb edit.html.erb found_sentences.html.erb index.html.erb new.html.erb show.html.erb
[~/rails_projects/blt]$cd app
[~/rails_projects/blt/app]$cd views
[~/rails_projects/blt/app/views]$cd application
bash: cd: application: No such file or directory
[~/rails_projects/blt/app/views]$ls
content dictionary_entries home lessons users
devise hints layouts user_mailer
[~/rails_projects/blt/app/views]$