在两个控制器中获取语法错误,为什么?

时间:2014-09-19 16:06:50

标签: ruby-on-rails ruby

您好我的两个控制器,帖子和成员都遇到两个语法错误。

我试图看到其他人遇到同样的错误,但我无法找到解决我的具体问题的方法。今天我在编写成员控制器,模型和视图时没有弄乱Post Controller,所以我想知道为什么我在这个特定的控制器中出现错误?

我将不胜感激。

谢谢! 埃里克

C:/community/app/controllers/posts_controller.rb:75:语法错误,意外的keyword_end,期待$ end

C:/community/app/controllers/members_controller.rb:14:语法错误,意外$ end,期待keyword_end

class PostsController < ApplicationController
  before_action :set_post, only: [:show, :edit, :update, :destroy]

  # GET /posts
  # GET /posts.json
  def index
    @posts = Post.all
  end

  # GET /posts/1
  # GET /posts/1.json
  def show
  end

  # GET /posts/new
  def new
    @post = Post.new
  end

  # GET /posts/1/edit
  def edit
  end

  # POST /posts
  # POST /posts.json
  def create
    @post = Post.new(post_params)

    respond_to do |format|
      if @post.save
        format.html { redirect_to @post, notice: 'Post was successfully created.' }
        format.json { render :show, status: :created, location: @post }
      else
        format.html { render :new }
        format.json { render json: @post.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /posts/1
  # PATCH/PUT /posts/1.json
  def update
    respond_to do |format|
      if @post.update(post_params)
        format.html { redirect_to @post, notice: 'Post was successfully updated.' }
        format.json { render :show, status: :ok, location: @post }
      else
        format.html { render :edit }
        format.json { render json: @post.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /posts/1
  # DELETE /posts/1.json
  def destroy
    @post.destroy
    respond_to do |format|
      format.html { redirect_to posts_url, notice: 'Post was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

private
  # Use callbacks to share common setup or constraints between actions.
  def set_post
    @post = Post.find(params[:id])
  end

  # Never trust parameters from the scary internet, only allow the white list through.
  def post_params
    params.require(:post).permit(:title, :date, :entry)
  end
end
end


class MembersController < ApplicationController
  def new
    @member = Member.new
  end

  def create
    @member = Member.new(params[:member])
    if @member.save
      redirect_to root_url, :notice => "Signed up!"
    else
      render "new"
    end
  end

1 个答案:

答案 0 :(得分:1)

end第75行还有posts_controller.rb,而end

末尾没有members_controller.rb