Я пытаюсь интегрировать forem с thumbs_up. Я унаследовал модель и контроллер forem Post.routing issue rails 3.1 thums_up and forem
Вот мой контроллер: -
class PostsController < Forem::PostsController
def vote_up
begin
current_user.vote_for(@post = Post.find(params[:id]))
render :nothing => true, :status => 200
rescue ActiveRecord::RecordInvalid
render :nothing => true, :status => 404
end
end
end
Вот как сообщение Контроллер ФОРЕМ выглядит следующим образом: -
module Forem
class PostsController < Forem::ApplicationController
before_filter :authenticate_forem_user
before_filter :find_topic
.
.
.
.
private
def find_topic
@topic = Forem::Topic.find(params[:topic_id])
end
end
end
Вот мои маршруты: -
mount Forem::Engine, :at => "/forums"
resources :posts do
member do
post :vote_up
end
end
Здесь is my view: -
<%= link_to t('vote for this post!', :scope =>"forem.post"), main_app.vote_up_post_path(@post), :method => :post %>
Это ошибка, которую я получаю: -
ActiveRecord :: RecordNotFound в PostsController # vote_up
Не удалось найти ФОРЭЙ :: Темы без ID
Что может быть проблема?
Как выглядит 'current_user.vote_for'? –
@muistooshort, что вы имеете в виду, как выглядит current_user.vote_for?vote_for предоставлен thumbs_up gem –
Похоже, что 'current_user.vote_for' делает вызов' Forem :: Topic.find', не давая ему идентификатора, вот что сообщение об ошибке, кажется, говорит вам, и я ничего не вижу что может вызвать его, поэтому мне интересно, почему 'vote_for' делает то, чего он не должен делать. –