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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:37:19+00:00 2026-06-06T16:37:19+00:00

I am a newbie RoR developer. I am stuck in one problem. I am

  • 0

I am a newbie RoR developer. I am stuck in one problem. I am trying to make a application with users who can create a topic and others can post their comments under the topic..The topics are created by user and listed on the main page as a list. I am almost done with the topics. But when i click them to see the posts, I get Couldn’t find Topic without an ID error.

I guess that my mistake is topics has two indexes id and user_id.
here is my Topic model :

class Topic < ActiveRecord::Base
  attr_accessible :content, :title
  belongs_to    :user
  has_many      :posts
  validates :title, presence: true, length: { maximum: 140 }
  validates :content, presence: true
  validates :user_id, presence: true
  default_scope order: 'topics.created_at DESC'
end

And my post model

class Posts < ActiveRecord::Base
  attr_accessible :content 
  belongs_to :topic
  belongs_to :user
  validates :user_id, presence: true
  validates :content, presence: true
  default_scope order: 'posts.created_at DESC'
end

this is my topics_controller.rb:

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

    def show
        @topic = Topic.find(params[:id])
        @posts = @topic.posts.paginate :page => params[:page], :per_page => 20
    end
       .
       ..vs

and this is my config/routes.rb

MyPedia::Application.routes.draw do
    resources :users
    resources :sessions, only: [:new, :create, :destroy]
    resources :topics, only: [:show, :create, :destroy]
    resources :posts
    root to: 'static_pages#home'


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

    match '/help',    to: 'static_pages#help'
    match '/about',   to: 'static_pages#about'
    match '/contact', to: 'static_pages#contact'

my topics show.html.erb

<% title @topic.title %>  
<div class ="center">
<h3><%= @topic.title %></h3>  

<% if @posts? %>  


  <% for post in @posts do %>  
    <p><strong><%= post.content %>  
  <% end %>  
<% end %>  
</div> 

I try to find a way to solve this problem.
thanks for helps

  • 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-06T16:37:21+00:00Added an answer on June 6, 2026 at 4:37 pm

    Try using GET /topic/1, that will help. The way you have set up the matched route is wrong and probably redundant. You can have a look here for more info: http://guides.rubyonrails.org/routing.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im a newbie RoR kid, and I'm trying to make a web gallery app
I am a newbie in ROR developement. I am trying to create my own
I'm a newbie spanish Rails developer. ¿Can u help me with a problem with
I am a complete newbie in working with a Ruby on Rails (RoR) application.
I'm a RoR newbie, trying to run the todos example using the readme .
Newbie C++ programmer here. I'm trying to write a command line application that takes
I'm an RoR newbie working to create a hosted task management/workflow solution and am
I'm a newbie to RoR, GitHub and Heroku, so I'm still trying to figure
Being a newbie ROR developer I've been thinking of ways of protecting certain methods
Absolute RoR newbie here, I'm trying to render out multiple leagues in a loop,

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.