2017-09-24 49 views
-2

當我嘗試加載我收到以下錯誤信息的頁面:語法錯誤,意外(阿根廷,預計在Rails的keyword_do錯誤信息

語法錯誤,意想不到的(阿根廷,keyword_do期待或「{」或「(」的link_to「UP」,link_vote_path(鏈接))

在基準線指向是這裏的第二個和第三個行:

<td><%= link.totalcount %></td> 
    <td><%= link_to "UP", link_vote_path (link) %></td> 
    <td><%= link_to "DOWN", link_down_vote_path (link) %></td> 

我相信我已經制定了正確的路線,所以我對於錯誤信息有點困惑。

基本上我試圖在Rails中添加一個簡單的計數器,允許投票上下。使用以下路線:

  link_vote GET /links/:link_id/vote(.:format)  links#vote 
     link_link_vote GET /links/:link_id/link_vote(.:format) links#link_vote 
     link_down_vote GET /links/:link_id/down_vote(.:format) links#down_vote 

而且在我的控制下:

def create 
    @link = Link.new(link_params) 
    @link.user = current_user 
    @link.totalcount = @link.votes.count 
     if @link.save 
     redirect_to @link 
     else 
     render :new 
     end 
    respond_to do |format| 
     if @link.save 
     format.html { redirect_to @link, notice: 'Link was successfully created.' } 
     format.json { render :show, status: :created, location: @link } 
     else 
     format.html { render :new } 
     format.json { render json: @link.errors, status: :unprocessable_entity } 
     end 
    end 
    end 

    def vote 
    if current_user 
     @link.vote << Vote.create!(user_id: @link.user_id, link_id: @link.id) 
     @link.totalcount = @link.votes.count 
     @link.save 
     redirect_to :root 
    else 
     redirect_to :login 
    end 
    end 

    def link_vote 
    @link.votes << Vote.create!(user_id: @link.user_id, link_id: @link.id) 
    @link.totalcount = @link.votes.count 
    @link.save 
    redirect_to :root 
    end 

    def down_vote 
    @link.votes.last.destroy 
    @link.totalcount = @link.votes.count 
    @link.save 
    redirect_to :root 
    end 

我失去了我的控制器,它影響的是櫃檯的東西嗎?

+0

作爲一個新的人來使用Rails,不知道這是一個簡單的打字錯誤面前......這是一個有點殘酷。如果我知道這是一個關於空間的簡單更正,那麼我就不會來StackOverflow尋求幫助。 – user8387535

回答

0

不要把空間開括號的方法調用

<%= link_to "UP", link_vote_path(link) %> 
相關問題