我在跟踪一直存在告诉我的语法错误时遇到了很多麻烦,但是在我的生活中我看不到它! 我收到以下错误:
syntax error, unexpected keyword_ensure, expecting end-of-input
在第render :action => "modal", :layout => false
行
无论我做什么,我都无法摆脱它!请帮帮我!
def new
@appointment = Appointment.new
@appointment.patient = current_patient
@appointment.practice = current_practice
respond_to do |format|
if params[:layout] == 'modal'
render :action => "modal", :layout => false
else
format.html
format.json { render json: @appointment }
end
end
end
答案 0 :(得分:2)
更新:查看错误:
我认为你必须查看你的观看代码。我想你误解了你的错误。我认为错误在您的视图模板中,而不在控制器操作中。在图片顶部的屏幕截图中,以下句子显示错误的位置:“app / views / appointmentments / new中的SyntaxError”。
控制器想要渲染视图 - 在视图中是错误 - 就是这样:)。
btw:可能的控制器重构:
def new
@appointment = Appointment.new
@appointment.patient = current_patient
@appointment.practice = current_practice
render :action => "modal", :layout => (params[:layout] == "modal" ? false : true)
end