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

  • Home
  • SEARCH
  • 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 7557113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:02:41+00:00 2026-05-30T12:02:41+00:00

I am having a bit of trouble with getting routing to work with single

  • 0

I am having a bit of trouble with getting routing to work with single table inheritance in my Rails 3.1 application. Right now I have two models that I am dealing with: a lesson and a segment. My application consists of lessons that have multiple different types of segments. These segments are of many different types which is why I am using single table inheritance. I have been able to confirm that my inheritance is working through the Rails Console but when I try to view different pages I run into problems. One of these pages is in the Lessons#show view. I get this error:

NoMethodError in Lessons#show
Showing web/app/views/lessons/show.html.erb where line #21 raised:
undefined method `web_segment_path' for #<#<Class:0x007f8faf1366b8>:0x007f8faf118320>

Here is the chunk of code where I get this error:

<% @segments.each do |segment| %>
  <tr>
    <td><%= segment.title %></td>
    <td><%= segment.segmenttype %></td>
        <td><%= segment.type %></td>
        <td><%= segment.url %></td>
        <td><%= segment.filepath %></td>
    <td><%= link_to 'Show', @segment %></td> <!-- This is the line with the error, if I remove this and the following two than everything is displayed properly -->
    <td><%= link_to 'Edit', edit_segment_path(segment) %></td>
    <td><%= link_to 'Destroy', segment, confirm: 'Are you sure?', method: :delete %></td>
  </tr>
<% end %>

I am confused because I never defined a route for web_segment_path, and I want it to route to segment as before, and just display every segment available regardless of types. I have set up the following models:

lesson.rb

class Lesson < ActiveRecord::Base
   belongs_to :course
   has_many :segments
end

segment.rb

class Segment < ActiveRecord::Base
  TYPE = ['FileSegment','WebSegment','MediaSegment','QuizSegment']
  belongs_to :lesson
end

web_segment.rb

class WebSegment < Segment
end

I know that I am missing inheritances for other types but right now I am focusing on just getting the WebSegment type working. Does anyone know why Rails would try to find the method ‘web_segment_path’ when I reference @segment? Like I said, the page will display if I remove the links to “show”, “edit”, and “delete.” Why would this be?

Thank you for any help!

  • 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-05-30T12:02:42+00:00Added an answer on May 30, 2026 at 12:02 pm

    Ok I figured this out myself and it was pretty obvious. I forgot to do some simple routing in my routes.rb file. In my case all I needed to add was one line:

    resources :web_segment, :controller => 'segments'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a bit of trouble getting my form validation to work. As of
I'm having a bit of trouble getting the right results from a query. At
I am having a bit of trouble getting Gravatars to work properly: When I
I'm having a tad bit of trouble getting the jQuery Form Plugin to work
I'm having a bit of trouble getting a SQL query to work. Some background
I am having a bit of trouble getting these polymorphic associations to work completely.
I am having a bit of trouble getting this c# code to work I
I'm having a bit of trouble getting a script to work within a CMS.
I'm having a bit of trouble getting a Python regex to work when matching
I've been having quite a bit of trouble getting an MVC2 web application to

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.