2016-11-07 89 views
-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相当陌生。语法错误,意外的输入结束

+0

解决您的不一致压痕问题变得非常明显。 – meagar

+1

由于您是ruby的新手,我建议您使用像Rubymine这样的IDE(https://www.jetbrains.com/ruby/)。它将帮助您保持正确的缩进以及其他许多方面。 –

回答

2

缺少的结果是针对create方法。你关闭了if-else和block而不是方法。

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. 

最终缺少

相关问题