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 8135627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:28:52+00:00 2026-06-06T10:28:52+00:00

I am writing an application , which User can create Topics and others can

  • 0

I am writing an application , which User can create Topics and others can make posts on that topic.

I am stuck with this error :

No route matches {:action=>"show", :controller=>"topics", :id=>nil}

my route.rb :

MyPedia2::Application.routes.draw do
    resources :users

    resources :sessions, only: [:new, :create, :destroy]
    resources :topics, only: [:show, :create, :destroy] 

  match '/signup',  to: 'users#new'
  match '/signin',  to: 'sessions#new'
  match '/signout', to: 'sessions#destroy', via: :delete

    root to: 'static_pages#home'

    match '/topics/:id', to: 'topics#show'

my rake route shows :

   topics POST   /topics(.:format)         topics#create
      topic GET    /topics/:id(.:format)     topics#show
            DELETE /topics/:id(.:format)     topics#destroy
    root        /                         static_pages#home
               /topics/:id(.:format)     topics#show

and my topics controller is:

# encoding: utf-8

class TopicsController < ApplicationController
    before_filter :signed_in_user, only: [:create, :destroy]
  before_filter :correct_user, only: :destroy


  def show
        @topic = Topic.find_by_id(params[:id])
  end

    def create
        @topic = current_user.topics.build(params[:topic])
        if @topic.save
            flash[:success] = "Konu oluşturuldu!"
            redirect_to root_path
        else
            render 'static_pages/home'
        end
    end

  def destroy
    @topic.destroy
    redirect_to root_path
  end
  private

    def correct_user
      @topic = current_user.topics.find_by_id(params[:id])
      redirect_to root_path if @topic.nil?
    end
end

Is there a fix for this ?
EDIT : I found that _topics.html.erb fails
I found what breakes the code :

<% for topic in @topics do %>  
  <li><%=link_to topic.title, topic_path(@topic) %></li>  

 <%= will_paginate @topics %>
<% end %>  

topic_path(@topic] part is wrong. How can i make it to use id?

  • 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-06T10:28:54+00:00Added an answer on June 6, 2026 at 10:28 am

    It’s not working because your collection is ‘@topics’, and each element is ‘topic’, not ‘@topic’. But you’re close. Try this:

    <li><%=link_to topic.title, topic_path(topic) %></li>  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an application that displays a list of objects which the user can
I'm writing an application for the iPhone that lets users create 3D models which
i am writing an application using mongodb in which user can send messages to
I am writing an iPhone application which requires the user to enter several values
I'm writing an android application which purpouse is to determine the user position via
I am writing a simple WinForms application in which I allow the user to
I am writing an android application, which communicates with server when the user logs
I am writing an application which is used for drawing widgets/menus/controls etc to create
I am writing an application that allows a user to submit a query to
I'm writing a depsktop application (in Java) that interacts with a database which stores

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.