Problems with form_for, STI, and polymorphic routing

I’m stumped on how to get past this. It’s Rails 2.0.2.

I have a class, Show. Using STI, I’m using that as a base class, and
have DayShow and NightShow that inherit from it.

class Show < ActiveRecord::Base

class DayShow < Show

In my shows/edit.html.erb, I have:

<% form_for(@show) do |f| %>

However, when I use it with a @show that has class DayShow, I get:

undefined method `day_show_path’ for #ActionView::Base:0x2382bb8

So it’s trying to use the STI class name, instead of the base class
name, to generate the routes.

Digging around on Google, it seems that a few people have run into
this, but I haven’t been able to find a solution. Can I use form_for
on an object that has STI in Rails 2.0, or do I need to build form
tags by hand?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs