语法错误rails render

时间:2013-09-16 13:02:14

标签: ruby-on-rails

我在跟踪一直存在告诉我的语法错误时遇到了很多麻烦,但是在我的生活中我看不到它! 我收到以下错误:

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

screen shot of better errrors stacktrace

1 个答案:

答案 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