理由はわかりませんが、新しいビューがクラッシュし始めました。
モデルチケットを持っています
class Ticket < ActiveRecord::Base
attr_accessible :body, :department, :email, :name, :reference, :subject, :status
has_many :replies, :dependent => :destroy
シンプルな新しいアクション
def new
logger.debug "#{@ticket}"
@ticket = Ticket.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @ticket }
end
end
および new.haml.html (間違った haml 形式で申し訳ありません):
= form_for @ticket do |f|
- if @ticket.errors.any?
#error_explanation
%h2= "#{pluralize(@ticket.errors.count, "error")} prohibited this ticket from being saved:"
%ul
- @ticket.errors.full_messages.each do |msg|
%li= msg
.field
= f.label :name
= f.text_field :name
.field
- if current_admin
= f.label :email
= f.text_field :email, :value => "#{current_admin.email}", :disabled => :true
- else
= f.label :email
= f.text_field :email
.field
= f.label :department
= f.select :department, options_for_select(["First department","Second department","Third department"])
.field
= f.label :subject
= f.text_field :subject
.field
= f.label :body
= f.text_area :body
- if current_admin
.field
= f.label :status
= f.select :status, options_for_select(["Waiting for Staff Response","Waiting for Customer","On Hold", "Cancelled", "Completed"])
.actions
= f.submit 'Save'
エラー:
ActionView::Template::Error (undefined method `model_name' for NilClass:Class):
1: = form_for @ticket do |f|
2: - if @ticket.errors.any?
3: #error_explanation
4: %h2= "#{pluralize(@ticket.errors.count, "error")} prohibited this ticket from being saved:"
app/views/tickets/_form.html.haml:1:in
`_app_views_tickets__form_html_haml__659380982_96991070'
Rendered /home/denmed/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-3.2.8/lib
/action_dispatch/middleware/templates/rescues/_trace.erb (5.9ms)
Rendered /home/denmed/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-3.2.8/lib
/action_dispatch/middleware/templates/rescues/_request_and_response.erb (4.1ms)
Rendered /home/denmed/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-3.2.8/lib
/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (42.2ms)
そしてroutes.rb
resources :tickets do
resources :comments
end
コンソールからチケットを作成できますが、どこに問題がありますか? 誰かがエラーの場所を提案できますか?