Missing model error

I am storing a shape object in a session, and somewhere I picked up that to make sure I can restore the full glory of Shape, I needed this line in ApplicationController

  model :Shape

So, of course, I also have a file /app/models/shape.rb

All was working well, but then I decided I'd rather name the model MyShape.

So, I
  - edited the filename to "my_shape.rb"
  - edited the shape.rb file to "class MyShape < AR"
  - edited "model :MyShape"

Now I get a "missing model error."

Dude, it's right there, I can see it.

However, I can't find where I picked up that I needed to add the 'model' line. So, I can't remember all the details of why it's there, what the rules are, what I am forgetting, etc.

Trying to figure out how to google for that one is a futile exercise.

Attempting to search various online docs for the Rails API are also fruitless.

Dazed, confused, and lost. And it was going so well for a while...

-- gw

Did you restart the server?

-Bill

I am storing a shape object in a session, and somewhere I picked up
that to make sure I can restore the full glory of Shape, I needed
this line in ApplicationController

  model :Shape

So, of course, I also have a file /app/models/shape.rb

All was working well, but then I decided I'd rather name the model
MyShape.

So, I
- edited the filename to "my_shape.rb"
- edited the shape.rb file to "class MyShape < AR"
- edited "model :MyShape"

Now I get a "missing model error."

Dude, it's right there, I can see it.

Have you tried clearing out your sessions. I'm guessing that it's
trying to restore your session, and since your session was created
before you made the change it contains an instance of Shape, not
MyShape.

However, I can't find where I picked up that I needed to add the
'model' line. So, I can't remember all the details of why it's there,
what the rules are, what I am forgetting, etc.

I thought that was dead.

Fred

Ahh yes, I bet Fredrick is correct on the fact that it is trying to
instantiate the incorrect class from a stale model and on the second
point that it is no longer needed.

-Bill

*stale session. (what I get for doing 3 things at once)

-Bill

I am storing a shape object in a session, and somewhere I picked up
that to make sure I can restore the full glory of Shape, I needed
this line in ApplicationController
  model :Shape
So, of course, I also have a file /app/models/shape.rb

All was working well, but then I decided I'd rather name the model
MyShape. So, I
- edited the filename to "my_shape.rb"
- edited the shape.rb file to "class MyShape < AR"
- edited "model :MyShape"

Now I get a "missing model error."

Have you tried clearing out your sessions.

Yes.

Did you restart the server?

Yes.

In fact at this point, I'm trying both Shape and MyShape.

So I have all the original Shape code. And it works.

Then I have a new model (created by generate) called MyShape.

I add the line

  model :MyShape

and even though I don't actually use it anywhere yet, I get that error. You'd think all it has to do at that point is look for that file, yeah? Weird.

However, I can't find where I picked up that I needed to add the
'model' line. So, I can't remember all the details of why it's there,
what the rules are, what I am forgetting, etc.

I thought that was dead.

So I don't even need to bother with this 'model' declaration? There's no circumstances where it is needed (perhaps when not following some convention?)

-- gw

Yeah, I figured. I appreciate that helping me was one of those things :slight_smile:

So, anyway, I nuked the model line, changed my names as needed, and everything works fine. So, for now I'll just forget this ever happened, and worry about model :x some other day when I need to.

Thanks guys.

-- gw