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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:34:27+00:00 2026-06-06T14:34:27+00:00

# Explaining the context puts I am learning Rails, building a simple forum application.

  • 0

# Explaining the context

puts "I am learning Rails, building a simple forum application."
puts "I am pretty satisfied to where I got so far but routes... "
puts "...still figuring them out."
puts "Been 2 days trying all sorts of things."
puts "This is where I am now, and something is not working as expected."
puts "Any help/pointers would be appreciated! :)"

# config/routes.rb

scope "/helpcenter" do
  resources :cat, :controller => "forums", :as => :forums do
    resources :topics , :controller => "forum_topics", :as => :topics
    resources :posts, :controller => "forum_posts", :as => :posts
  end
end

match "/helpcenter" => "forums#index", :as => :forums

# app/models/forum.rb

class Forum < ActiveRecord::Base
  def to_param
    "#{id}-#{name.parameterize}"
  end
end

# app/models/forum_topic.rb

class ForumTopic < ActiveRecord::Base
  def to_param
    "#{id}-#{name.parameterize}"
  end
end

# app/controllers/forums/show.hmtl.erb

link_to @forum_topic.name, forum_topic_path(@forum_topic)
# OR
link_to @forum_topic.name, @forum_topic

# What is being generated by link_to :

"/helpcenter/cat/1-first-topic/topics/1-first-forum"

# What I expected to see (because topics should be in forums):

"/helpcenter/cat/1-first-forum/topics/1-first-topic"

# What am I doing wrong?

puts "Thanks!"
  • 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-06T14:34:28+00:00Added an answer on June 6, 2026 at 2:34 pm

    The primary paths should be:

    forum_topic_path(@forum, @topic)  
    forum_topics_path(@forum)
    

    The param (@forum_topic) you passed in

    link_to @forum_topic.name, forum_topic_path(@forum_topic)
    

    Has one :id associated with it (1), so it will show the forum with id=1. You should also be passing the topic id

    forum_topic_path(@forum, @topic)
    

    Surprised you didn’t get an error without the id–I am guessing that it inferred the :id to both resources.

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

Sidebar

Related Questions

I am having trouble explaining this to myself but here is my best attempt.
Recently while I was explaining the basic difference between pointers and references(in context of
In a Rails application, I need a table in my database to contain constant
I'm building my application with Entity Framework (model first principle). I'm also using MS
I'm not very good at explaining in english but i'll give it a go.
I first got an error usign the code below, explaining that DataGridLinkButton' must be
The Context: It appears that the simple scjp ->scja->.... tracks for sun certification have
First explaining what is on my mind {I'm not good at English} On Alan
When explaining Clojure builds, I would like to use the correct terminology. Therefore my
Is there a book explaining the design of FAT32, NTFS, ReiserFS, ext2, ext3, ext4,

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.