Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7971609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:40:33+00:00 2026-06-04T07:40:33+00:00

I am implementing a like system in my rails app using David Celis gem

  • 0

I am implementing a like system in my rails app using David Celis gem called Recommendable. I’ve gotten everything to work in the console but I can’t get the right routes and I’m getting the “No route matches [GET] “/categories/1/posts/1/like” error.

I have the following in my models:

class Category < ActiveRecord::Base
  has_many :posts, :dependent => :destroy
  extend FriendlyId
  friendly_id :name, use: :slugged
end

class Post < ActiveRecord::Base
  belongs_to :category
end

In my Post Controller I have:

class PostsController < ApplicationController
  before_filter :authenticate_user!
  before_filter :get_category
  def like
    @post = Post.find(params[:id])
    respond_to do |format|
      if current_user.like @post
      else
         flash[:error] = "Something went wrong! Please try again."
         redirect_to show_post_path(@category, @post)
      end
    end
  end
end

In my routes I have:

resources :categories do
    resources :posts do
      put :like, :on => :member
    end
end
match 'categories/:category_id/posts/:id', :to => 'posts#show', :as => 'show_post'

Can someone please point at my errors? I can get the PUT to work but I dont know where the GET error is coming from as I am trying to redirect back to the post if an error occurs when the user like’s a certain post. Thank you in advance.

EDIT:

In my view I have:

- title "#{@post.class}"
%p#notice= notice

%p
  %b Title:
  = @post.title
%p
  %b Description:
  = @post.description
%p
  %b Likes:
  = @post.liked_by.count

= link_to 'Edit', edit_category_post_path(@post)
\|
= link_to 'Back', category_posts_path
\|
= link_to 'Like', like_category_post_path(@post)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:40:35+00:00Added an answer on June 4, 2026 at 7:40 am

    Replace:

    = link_to 'Like', like_category_post_path(@post)
    

    with:

    = link_to 'Like', like_category_post_path(@category, @post), method: :put
    

    Or, as I like it:

    = link_to 'Like', [@category, @post], method: :put
    

    I think your like has to be:

    def like
      @post = Post.find(params[:id])
      respond_to do |format|
        format.html do
          if current_user.like @post
            flash[:notice] = "It's ok, you liked it!"
            redirect_to :back
          else
             flash[:error] = "Something went wrong! Please try again."
             redirect_to show_post_path(@category, @post)
          end
        end
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm implementing a relatively simple autosave system and I'd like to do so using
I have the work of implementing a distributed system of nodes (like p2p nodes)
I'm implementing global search box extension (sth like SearchableDictionary sample in android sdk). Everything
So I have an app that behaves like a photo gallery and I'm implementing
I'm working on an app that behaves like a photo gallery, and I'm implementing
I'm implementing a Stackoverflow-like reputation system on my rap lyrics explanation site, Rap Genius
What is the idea behind implementing a tagging system like Stack Overflow? This is
I am implementing a simple license-file system, and would like to know if there
Basically, I am implementing own cache system. Ideally, it'll look like this: $CACHE->start($name); //CODE
I have a Rails app acting as an OAuth 2.0 provider (using the oauth2-provider

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.