2012-05-29 109 views
-4

得到以下錯誤:軌語法錯誤..意外結束

SyntaxError in FriendsController#index 

/Users/nelsonkeating/Desktop/ReminDeal/app/controllers/friends_controller.rb:32: syntax error, unexpected keyword_end, expecting ')' 
/Users/nelsonkeating/Desktop/ReminDeal/app/controllers/friends_controller.rb:58: syntax error, unexpected $end, expecting keyword_end 
Rails.root: /Users/nelsonkeating/Desktop/ReminDeal 

Application Trace | Framework Trace | Full Trace 
activesupport (3.2.3) lib/active_support/dependencies.rb:469:in `load' 
activesupport (3.2.3) lib/active_support/dependencies.rb:469:in `block in load_file' 
activesupport (3.2.3) lib/active_support/dependencies.rb:639:in `new_constants_in' 
activesupport (3.2.3) lib/active_support/dependencies.rb:468:in `load_file' 
activesupport (3.2.3) lib/active_support/dependencies.rb:353:in `require_or_load' 
activesupport (3.2.3) lib/active_support/dependencies.rb:502:in `load_missing_constant' 
activesupport (3.2.3) lib/active_support/dependencies.rb:192:in `block in const_missing' 
activesupport (3.2.3) lib/active_support/dependencies.rb:190:in `each' 
activesupport (3.2.3) lib/active_support/dependencies.rb:190:in `const_missing' 
activesupport (3.2.3) lib/active_support/inflector/methods.rb:229:in `block in constantize' 
activesupport (3.2.3) lib/active_support/inflector/methods.rb:228:in `each' 
activesupport (3.2.3) lib/active_support/inflector/methods.rb:228:in `constantize' 
activesupport (3.2.3) lib/active_support/dependencies.rb:554:in `get' 
actionpack (3.2.3) lib/action_dispatch/routing/route_set.rb:69:in `controller_reference' 
actionpack (3.2.3) lib/action_dispatch/routing/route_set.rb:54:in `controller' 
actionpack (3.2.3) lib/action_dispatch/routing/route_set.rb:32:in `call' 
journey (1.0.3) lib/journey/router.rb:68:in `block in call' 
journey (1.0.3) lib/journey/router.rb:56:in `each' 
journey (1.0.3) lib/journey/router.rb:56:in `call' 
actionpack (3.2.3) lib/action_dispatch/routing/route_set.rb:600:in `call' 
client_side_validations (3.1.4) lib/client_side_validations/middleware.rb:18:in `call' 
warden (1.1.1) lib/warden/manager.rb:35:in `block in call' 
warden (1.1.1) lib/warden/manager.rb:34:in `catch' 
warden (1.1.1) lib/warden/manager.rb:34:in `call' 
actionpack (3.2.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call' 
rack (1.4.1) lib/rack/etag.rb:23:in `call' 
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call' 
actionpack (3.2.3) lib/action_dispatch/middleware/head.rb:14:in `call' 
actionpack (3.2.3) lib/action_dispatch/middleware/params_parser.rb:21:in `call' 
actionpack (3.2.3) lib/action_dispatch/middleware/flash.rb:242:in `call' 
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context' 
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call' 
actionpack (3.2.3) lib/action_dispatch/middleware/cookies.rb:338:in `call' 
activerecord (3.2.3) lib/active_record/query_cache.rb:64:in `call' 
activerecord (3.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:467:in `call' 
actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' 
activesupport (3.2.3) lib/active_support/callbacks.rb:405:in `_run__4243183701801146600__call__3008343249707344054__callbacks' 
activesupport (3.2.3) lib/active_support/callbacks.rb:405:in `__run_callback' 
activesupport (3.2.3) lib/active_support/callbacks.rb:385:in `_run_call_callbacks' 
activesupport (3.2.3) lib/active_support/callbacks.rb:81:in `run_callbacks' 
actionpack (3.2.3) lib/action_dispatch/middleware/callbacks.rb:27:in `call' 
actionpack (3.2.3) lib/action_dispatch/middleware/reloader.rb:65:in `call' 
actionpack (3.2.3) lib/action_dispatch/middleware/remote_ip.rb:31:in `call' 
actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' 
actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' 
railties (3.2.3) lib/rails/rack/logger.rb:26:in `call_app' 
railties (3.2.3) lib/rails/rack/logger.rb:16:in `call' 
actionpack (3.2.3) lib/action_dispatch/middleware/request_id.rb:22:in `call' 
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call' 
rack (1.4.1) lib/rack/runtime.rb:17:in `call' 
activesupport (3.2.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call' 
rack (1.4.1) lib/rack/lock.rb:15:in `call' 
actionpack (3.2.3) lib/action_dispatch/middleware/static.rb:62:in `call' 
railties (3.2.3) lib/rails/engine.rb:479:in `call' 
railties (3.2.3) lib/rails/application.rb:220:in `call' 
rack (1.4.1) lib/rack/content_length.rb:14:in `call' 
railties (3.2.3) lib/rails/rack/log_tailer.rb:14:in `call' 
thin (1.3.1) lib/thin/connection.rb:80:in `block in pre_process' 
thin (1.3.1) lib/thin/connection.rb:78:in `catch' 
thin (1.3.1) lib/thin/connection.rb:78:in `pre_process' 
thin (1.3.1) lib/thin/connection.rb:53:in `process' 
thin (1.3.1) lib/thin/connection.rb:38:in `receive_data' 
eventmachine (0.12.10) lib/eventmachine.rb:256:in `run_machine' 
eventmachine (0.12.10) lib/eventmachine.rb:256:in `run' 
thin (1.3.1) lib/thin/backends/base.rb:61:in `start' 
thin (1.3.1) lib/thin/server.rb:159:in `start' 
rack (1.4.1) lib/rack/handler/thin.rb:13:in `run' 
rack (1.4.1) lib/rack/server.rb:265:in `start' 
railties (3.2.3) lib/rails/commands/server.rb:70:in `start' 
railties (3.2.3) lib/rails/commands.rb:55:in `block in <top (required)>' 
railties (3.2.3) lib/rails/commands.rb:50:in `tap' 
railties (3.2.3) lib/rails/commands.rb:50:in `<top (required)>' 
script/rails:6:in `require' 
script/rails:6:in `<main>' 

我的觀點:

class FriendsController < ApplicationController 

    def index 
    @friends = Friend.all 
end 

    def show 
    @friend = Friend.find(params[:id]) 

    respond_to do |format| 
     format.html # show.html.erb 
     format.json { render json: @friend } 
    end 
    end 

    def new 
    @friend = Friend.new 

    respond_to do |format| 
     format.html # new.html.erb 
     format.json { render json: @friend } 
    end 
    end 

    def edit 
    @friend = Friend.find(params[:id]) 
    end 


    def create 
    @friend = Friend.new(params[:friend] 
    end 

    def update 
    @friend = Friend.find(params[:id]) 

    respond_to do |format| 
     if @friend.update_attributes(params[:friend]) 
     format.html { redirect_to @friend, notice: 'Friend was successfully updated.' } 
     format.json { head :no_content } 
     else 
     format.html { render action: "edit" } 
     format.json { render json: @friend.errors, status: :unprocessable_entity } 
     end 
    end 



    def destroy 
    @friend = Friend.find(params[:id]) 
    @friend.destroy 

    respond_to do |format| 
     format.html { redirect_to friends_url } 
     format.json { head :no_content } 
    end 
    end 
end 
+0

這不是視圖,這是控制器... – DGM

回答

5

看起來你缺少你的更新結束的結束:

@friend = Friend.find(params[:id]) 
    respond_to do |format| 
    if @friend.update_attributes(params[:friend]) 
     format.html { redirect_to @friend, notice: 'Friend was successfully updated.' } 
     format.json { head :no_content } 
    else 
     format.html { render action: "edit" } 
     format.json { render json: @friend.errors, status: :unprocessable_entity } 
    end 
    end 
end #add this one :) 

和你製作的是在它的末端缺少一個右括號:

def create 
    @friend = Friend.new(params[:friend]) 
end 
4

update方法缺少其end

+0

+1,半對;;) –

3

您的更新方法缺少一個結尾

相關問題