ruby-on-railsmodelvote-up-buttons

Overriding a model rails 3.1


I am trying to override a model of forem gem so that I could use thumbs_up gem for voting purpose.

I did a rails g model Post and trying to inherit the post model of forem by this line of code

class Post < Forem::Post

    acts_as_voteable
end

same for the controller

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

I keep getting this error

undefined method `vote_up_post_path'

in my route.rb

 mount Forem::Engine, :at => "/forums"


resources :posts do
  member do
    post :vote_up
  end
end

I guess I am doing something really stupid out here and I am not overriding the model correctly. I was using this Clarification on how to use "thumbs_up" voting gem with Rails 3 post to set up thumbs_up

Can someone help??


Solution

  • It seems it was a stupid mistake, realized it while having discussion with patrickmcgraw.

    forem hides your routes and and you have to mention main_app before the routes, so after writing

    main_app.vote_up_post_path instead of vote_up_post_path the page was up again.

    Hope it helps someone trying to use forem.