我道歉,这是我第一次发帖提问。 这是我的错误,我不明白或知道如何纠正这是导致错误的代码一切正常,直到这个
c:/Sites/helpdesk/app/controllers/tickets_controller.rb:99:语法错误,意外'=',期待tASSOC redirect_to:action => 'show',:id = flash [:ticket_id] ^
#action
def ticket_action
@act = Action.new(
"ticket_id" => flash[:ticket_id],
"description" => params[:description]['description'],
"user_id" => params[:actUser]['user_id']
)
id @act.save
flash[:notice] = 'Action was successfully added'
redirect_to :action => 'show', :id = flash[:ticket_id]
end
答案 0 :(得分:1)
unexpected '=', expecting tASSOC redirect_to :action => 'show', :id = flash[:ticket_id]
tASSOC
是=>
符号,因此ruby期待=>
而不是=
只需在行中替换它:
redirect_to :action => 'show', :id => flash[:ticket_id]
相当于:
redirect_to { :action => 'show', :id => flash[:ticket_id] }
Ruby允许您在最后一个参数为{}
Hash
加
id @act.save
应该是
if @act.save