# Does every model need a corresponding Controller and View?

**URL:** <https://www.ruby-forum.com/t/does-every-model-need-a-corresponding-controller-and-view/73302>\
**Category:** Rails\
**Created:** [October 23, 2006, 6:03pm UTC](https://www.ruby-forum.com/t/does-every-model-need-a-corresponding-controller-and-view/73302 "2006-10-23T18:03:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 23, 2006, 6:03pm UTC](https://www.ruby-forum.com/t/does-every-model-need-a-corresponding-controller-and-view/73302/1 "2006-10-23T18:03:37Z")

</div>

or is there a way to intialize a model in another controller ?  
Right now I’m getting

uninitialized constant CandidatesController:Canindustry

TIA  
stuart

–

> **[Dark ambient](https://en.wikipedia.org/wiki/Dark_ambient)**
>
> Dark ambient (referred to as ambient industrial especially in the 1980s) is a genre of post-industrial music that features an ominous, dark droning and often gloomy, monumental or catacombal atmosphere, partially with discordant overtones. It shows similarities with ambient music, a genre that has been cited as a main influence by many dark ambient artists, both conceptually and compositionally. Although mostly electronically generated, dark ambient also includes the sampling of hand-pla 
> The te...

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 23, 2006, 6:17pm UTC](https://www.ruby-forum.com/t/does-every-model-need-a-corresponding-controller-and-view/73302/2 "2006-10-23T18:17:40Z")

</div>

Dark A. wrote:

> or is there a way to intialize a model in another controller ?  
> Right now I’m getting
> 
> uninitialized constant CandidatesController:Canindustry

The short answer is no. Just make sure Canindustry is correctly spelled.  
Perhaps its CanIndustry if the model file name is can\_industry.

Another option (some times required) is to add the following in the  
controller.

class FooController  
model ‘can\_industry’ # or is it ‘canindustry’  
…  
end

Long  
www.edgesoft.ca

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 23, 2006, 6:23pm UTC](https://www.ruby-forum.com/t/does-every-model-need-a-corresponding-controller-and-view/73302/3 "2006-10-23T18:23:41Z")

</div>

On 10/23/06, Long [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Another option (some times required) is to add the following in the controller.
> 
> class FooController  
> model ‘can\_industry’ # or is it ‘canindustry’  
> …  
> end

What Long said. Plus, it looks like your scope operator was mistyped.  
Should be :: instead of :.

– James

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 23, 2006, 6:37pm UTC](https://www.ruby-forum.com/t/does-every-model-need-a-corresponding-controller-and-view/73302/4 "2006-10-23T18:37:50Z")

</div>

On 10/23/06, JDL [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > The short answer is no. Just make sure Canindustry is correctly spelled.
> 
> What Long said. Plus, it looks like your scope operator was mistyped.  
> Should be :: instead of :.
> 
> – James

the model for clarification is -  
class Canindustry \< ActiveRecord::Base

with file name spelled canindustry.rb

Things seemed to be spelled correctly. I tried adding model  
‘canindustry’  
and was met with

undefined method `model’ for #CandidatesController:0x8481ba0

Not sure what’s going on .  
Stuart

–

> **[Dark ambient](https://en.wikipedia.org/wiki/Dark_ambient)**
>
> Dark ambient (referred to as ambient industrial especially in the 1980s) is a genre of post-industrial music that features an ominous, dark droning and often gloomy, monumental or catacombal atmosphere, partially with discordant overtones. It shows similarities with ambient music, a genre that has been cited as a main influence by many dark ambient artists, both conceptually and compositionally. Although mostly electronically generated, dark ambient also includes the sampling of hand-pla 
> The te...

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 23, 2006, 6:31pm UTC](https://www.ruby-forum.com/t/does-every-model-need-a-corresponding-controller-and-view/73302/5 "2006-10-23T18:31:42Z")

</div>

JDL wrote:

> > Perhaps its CanIndustry if the model file name is can\_industry.  
> > Should be :: instead of :.

Good catch James!

Long

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 23, 2006, 7:16pm UTC](https://www.ruby-forum.com/t/does-every-model-need-a-corresponding-controller-and-view/73302/6 "2006-10-23T19:16:04Z")

</div>

Hi Stuart,

Dark A. wrote:

> is there a way to intialize a model in another controller ?

Just include the following line in your controller.

model :model\_name

hth,  
Bill

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 23, 2006, 7:20pm UTC](https://www.ruby-forum.com/t/does-every-model-need-a-corresponding-controller-and-view/73302/7 "2006-10-23T19:20:06Z")

</div>

On 10/23/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> #CandidatesController:0x8481ba0
> 
> Not sure what’s going on .  
> Stuart

What are you trying to do? You shouldn’t have to do anything special  
to use a model in a controller. The models (by design) have no clue  
about controllers at all. They aren’t tied to any specific  
controller, unless you’ve hacked something in that we don’t know  
about.

If you post the code that is actually breaking, we might be able to  
help. Otherwise, it’s just guessing.

– James

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [October 23, 2006, 7:41pm UTC](https://www.ruby-forum.com/t/does-every-model-need-a-corresponding-controller-and-view/73302/8 "2006-10-23T19:41:39Z")

</div>

On 10/23/06, JDL [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ‘canindustry’  
> about controllers at all. They aren’t tied to any specific  
> controller, unless you’ve hacked something in that we don’t know  
> about.
> 
> If you post the code that is actually breaking, we might be able to  
> help. Otherwise, it’s just guessing.

Hey guys , it’s working now ! For whatever reason writing model  
‘mymodel’  
didn’t take and got an exception thrown.  
model :mymodel though did the trick.

Very nice.Appreciate all the help.

Stuart
