-3
class PinsController < ApplicationController
before_action :set_pin, only: [:show, :edit, :update, :destroy]
def index
@pins = Pin.all
end
def show
end
def new
@pin = Pin.new
end
def edit
end
def create
@pin = Pin.new(pin_params)
respond_to do |format|
if @pin.save
redirect_to @pin, notice: 'Pin was successfully created.' }
else
render action: 'new'
end
end
def update
if @pin.update(pin_params)
redirect_to @pin, notice: 'Pin was successfully updated.'
else
render action: 'edit'
end
end
def destroy
@pin.destroy
redirect_to pins_url
end
private
# Use callbacks to share common setup or constraints between actions.
def set_pin
@pin = Pin.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def pin_params
params.require(:pin).permit(:description)
end
end
我知道我缺少或需要添加幾個'結束'。但是,我只是不知道在哪裏。謝謝:)我真的很感激有人幫助我看到我出錯的地方。我對軌道上的ruby相當陌生。語法錯誤,意外的輸入結束
解決您的不一致壓痕問題變得非常明顯。 – meagar
由於您是ruby的新手,我建議您使用像Rubymine這樣的IDE(https://www.jetbrains.com/ruby/)。它將幫助您保持正確的縮進以及其他許多方面。 –