gpt4 book ai didi

ruby-on-rails - 获取语​​法错误,输入意外终止

转载 作者:行者123 更新时间:2023-12-03 08:14:29 25 4
gpt4 key购买 nike

尽管检查了代码,但我仍然收到语法错误,意外的输入终止,甚至在删除代码并运行它之后,问题似乎也没有解决。以下是代码:

class BookingsController < ApplicationController

before_filter :authenticate_user!

def new
@booking = Booking.new
end

def create
@booking = current_user.booking.create(booking_params)
if @booking.save
flash[:alert] = "You have now booked a date"
redirect_to root_path
else
flash[:alert] = "Error:booking did not save"
redirect_to root_path
render 'new'
end
end


def show
@booking = Booking.find(params[:id])
end

def edit
@booking = Booking.find(params[:id])

unless @booking.user == current_user
redirect_to root_path
end
end

def update
@booking = Booking.find(params[:id])
unless @booking.user == current_user
redirect_to root_path

if @booking.update_attributes(booking_params)
redirect_to root_path
flash[:notice] = "You have edited your post"
else
render 'edit'
flash[:alert] = "something went wrong"
end
end

def destroy
@booking = Booking.find(params[:id])
@booking.destroy
redirect_to root_path
end

private
def booking_params
params.require(:booking).permit(:content)
end

end

最佳答案

您在这里错过了end关键字

def update 
@booking = Booking.find(params[:id])
unless @booking.user == current_user
redirect_to root_path
end # <~~~ missed in your code
if @booking.update_attributes(booking_params)
redirect_to root_path
flash[:notice] = "You have edited your post"
else
render 'edit'
flash[:alert] = "something went wrong"
end
end

关于ruby-on-rails - 获取语​​法错误,输入意外终止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21708575/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com