1. Vote_Fu для Rails 3 2. Я не знаю, что я делаю 3. ???4. Прибыль - PullRequest
0 голосов
/ 11 июня 2011

Я пишу свое первое настоящее приложение на Rails и пытаюсь реализовать плагин voice_fu для rails three.Я пытался следовать примерам, включенным в плагин, но он не работает.

Я смог проголосовать за мою модель для голосования в окне консоли.

Итак, у меня есть Темыкоторый имеет много тем, ссылок, и модель для голосования является моделью ссылок.именно пользователи голосуют за модель.Теперь мои маршруты выглядят так:

resources :topics do
    resources :links do 
      resources :votes
    end
end

resources :users do 
   resources :votes
end

Это ошибка, которую я получаю:

NoMethodError in Topics#show
Showing /app/views/links/_link.html.erb where line #8 raised:
undefined method `user_topic_links_votes_path' for #<#<Class:0x23aede4>:0x23ad138>
Extracted source (around line #8):
6:       <span class="upvote">
7:         <%= link_to_remote image_tag('upvote.png'),
8:           :url => user_topic_links_votes_path(current_user, link,
9:                 :vote => :true, :format => :html), 
10:         :method => :post
11:     %> 

_link.html.erb

<!-- Link partial-->
<ul class="topicLinks">
  <% @topic.links.each do |link| %>
    <li>

      <span class="upvote">
        <%= link_to_remote image_tag('upvote.png'),
          :url => user_topic_links_votes_path(current_user, link,
                :vote => :true, :format => :html), 
        :method => :post
    %> 
      </span>
      <span class="downvote">
      <%= link_to_remote image_tag('downvote.png'),
      :url => user_topic_links_votes_path(current_user, link,
          :vote => :false, :format => :html), 
          :method => :post
      %>
      </span>

      <span class="vote_tally"><%= vote_tally(link) %></span>
        <%= link_to link.url, url_with_protocol(link.url), :target => :blank %>
      </li>
    <li><i><%= link.description %></i></li>
  <% end %>
</ul>

voice_Controller.rb

def create
  @link = @topic.links.find(params[:id])

  respond_to do |format|
    if current_user.vote(@link, params[:vote])
      format.html { redirect_to([current_user, @link]) }
      format.xml  { render :xml => @vote, :status => :created, :location => @vote }
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @vote.errors, :status => :unprocessable_entity }
    end
  end
end

Как я уже сказал, я действительно не знаю, что делаю ... очень жаль, если это что-то вроде мусора.

...