语法错误,意外的输入结束

时间:2016-11-07 12:49:57

标签: ruby-on-rails ruby

    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

我知道我失踪了或者需要添加几个'结束'。但是,我只是不确定在哪里。谢谢:)我真的很感谢有人帮我看看我哪里出错了。我对铁轨上的红宝石很新。

2 个答案:

答案 0 :(得分:2)

缺少的结尾是build方法。你关闭了if-else和块,但没有关闭方法。

答案 1 :(得分:2)

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
end #this end is missing on your code.

结束了