# Unitialized constant controller

**URL:** <https://www.ruby-forum.com/t/unitialized-constant-controller/195686>\
**Category:** Rails\
**Created:** [September 28, 2010, 7:02am UTC](https://www.ruby-forum.com/t/unitialized-constant-controller/195686 "2010-09-28T07:02:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![binbash-x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@binbash-x](https://www.ruby-forum.com/u/binbash-x)\
**Post date:** [September 28, 2010, 7:02am UTC](https://www.ruby-forum.com/t/unitialized-constant-controller/195686/1 "2010-09-28T07:02:37Z")

</div>

Hey guys,

Here’s an error I get after I hit the submit button on the editing  
page:

NameError in ClassifiedsController#update

uninitialized constant ClassifiedsController

Help would be appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![binbash-x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@binbash-x](https://www.ruby-forum.com/u/binbash-x)\
**Post date:** [September 28, 2010, 10:36am UTC](https://www.ruby-forum.com/t/unitialized-constant-controller/195686/2 "2010-09-28T10:36:20Z")

</div>

On Sep 28, 6:02 am, Faisal B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hey guys,
> 
> Here’s an error I get after I hit the submit button on the editing  
> page:
> 
> NameError in ClassifiedsController#update
> 
> uninitialized constant ClassifiedsController

Does that controller exist (and in the right place) ?

Fred

---

<div class="post-metadata">

**Author:** ![binbash-x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@binbash-x](https://www.ruby-forum.com/u/binbash-x)\
**Post date:** [September 28, 2010, 12:31pm UTC](https://www.ruby-forum.com/t/unitialized-constant-controller/195686/3 "2010-09-28T12:31:45Z")

</div>

On 28 September 2010 10:05, Faisal B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Please don’t top post, it makes it difficult to follow the thread

> hi, Yes the below code is what I have i.e update method in

Presumably the ‘yes’ is in response to Fred’s question: ‘Does that  
controller exist (and in the right place) ?’

> Classifieds\_controller.rb…

It should be classifieds\_controller.rb (lower case) though I do not  
know whether that is the root of the problem.

Colin

---

<div class="post-metadata">

**Author:** ![binbash-x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@binbash-x](https://www.ruby-forum.com/u/binbash-x)\
**Post date:** [September 28, 2010, 11:05am UTC](https://www.ruby-forum.com/t/unitialized-constant-controller/195686/4 "2010-09-28T11:05:13Z")

</div>

hi, Yes the below code is what I have i.e update method in  
Classifieds\_controller.rb…

def edit  
@classifed = Classified.find(params[:id])  
end

def update  
@classifed = Classified.find(params[:id])  
if @classified.update\_attributes(params[:classified])  
flash[:notice] = “updated”  
redirect\_to @classified  
else  
render :action =\> ‘edit’  
end  
end

Edit.rhtml

# Editing Classified: \<%= :title -%\>

\<% form\_for @classified do |form| %\>  
\<%=form.error\_messages%\>

\<%=form.label :title%\>  
 \<%= form.text\_field :title %\>

\<%=form.label :price%\>  
 \<%= form.text\_field :price %\>

\<%=form.label :location%\>  
 \<%= form.text\_field :location %\>

\<%=form.label :description%\>  
 \<%= form.text\_area :description %\>

\<%=form.label :email%\>  
 \<%= form.text\_field :email %\>

\<%= submit\_tag “save changes” %\>  
\<% end %\>  
\<%= link\_to ‘Back’, {:action =\> ‘list’} %\>

Thanks

Frederick C. wrote:

> On Sep 28, 6:02ï¿½am, Faisal B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Hey guys,
> > 
> > Here’s an ï¿½error I get after I hit the submit button on the editing  
> > page:
> > 
> > NameError in ClassifiedsController#update
> > 
> > uninitialized constant ClassifiedsController
> 
> Does that controller exist (and in the right place) ?
> 
> Fred

---

<div class="post-metadata">

**Author:** ![binbash-x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@binbash-x](https://www.ruby-forum.com/u/binbash-x)\
**Post date:** [September 28, 2010, 4:19pm UTC](https://www.ruby-forum.com/t/unitialized-constant-controller/195686/5 "2010-09-28T16:19:46Z")

</div>

Colin L. wrote:

> On 28 September 2010 10:05, Faisal B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> Please don’t top post, it makes it difficult to follow the thread
> 
> > hi, Yes the below code is what I have i.e update method in
> 
> Presumably the ‘yes’ is in response to Fred’s question: ‘Does that  
> controller exist (and in the right place) ?’
> 
> > Classifieds\_controller.rb…
> 
> It should be classifieds\_controller.rb (lower case) though I do not  
> know whether that is the root of the problem.
> 
> Colin

Cool, Now I understand…I think…

Classifieds\_controller.rb…

def edit  
@classifed = Classified.find(params[:id])  
end

def update  
@classifed = Classified.find(params[:id])  
if @classified.update\_attributes(params[:classified])  
flash[:notice] = “updated”  
redirect\_to @classified  
else  
render :action =\> ‘edit’  
end  
end

Edit.rhtml

# Editing Classified: \<%= :title -%\>

\<% form\_for @classified do |form| %\>  
\<%=form.error\_messages%\>

\<%=form.label :title%\>  
 \<%= form.text\_field :title %\>

\<%=form.label :price%\>  
 \<%= form.text\_field :price %\>

\<%=form.label :location%\>  
 \<%= form.text\_field :location %\>

\<%=form.label :description%\>  
 \<%= form.text\_area :description %\>

\<%=form.label :email%\>  
 \<%= form.text\_field :email %\>

\<%= submit\_tag “save changes” %\>  
\<% end %\>  
\<%= link\_to ‘Back’, {:action =\> ‘list’} %\>

Thanks
