# Whats this error (uninitialized constant)?

**URL:** <https://www.ruby-forum.com/t/whats-this-error-uninitialized-constant/86058>\
**Category:** Rails\
**Created:** [February 19, 2007, 3:34pm UTC](https://www.ruby-forum.com/t/whats-this-error-uninitialized-constant/86058 "2007-02-19T15:34:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jamal](https://www.ruby-forum.com/u/jamal)\
**Post date:** [February 19, 2007, 3:34pm UTC](https://www.ruby-forum.com/t/whats-this-error-uninitialized-constant/86058/1 "2007-02-19T15:34:23Z")

</div>

Hi,

I get this error whenever I try to create new row (db)

uninitialized constant BlogController::Blog

my controller looks like this:

class BlogController \< ApplicationController

layout “index”

def create  
if request.post?  
@blog = Blog.new(params[:blog])  
if @blog.save  
flash[:notice] = ‘Blog was successfully created.’  
redirect\_to :action =\> ‘list’  
else  
render :action =\> ‘new’  
end  
end  
end

end

and this is my view simple…

\<%= form\_tag(‘create’) %\>

Title\<%= text\_field "blog", "title", "size" =\> 20 %\>Comments\<%= submit\_tag("Add New Title") %\>

\<%= end\_form\_tag %\>

why does that error happens (uninitialized constant  
BlogController::Blog)?

---

<div class="post-metadata">

**Author:** ![jamal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jamal](https://www.ruby-forum.com/u/jamal)\
**Post date:** [February 19, 2007, 4:00pm UTC](https://www.ruby-forum.com/t/whats-this-error-uninitialized-constant/86058/2 "2007-02-19T16:00:57Z")

</div>

Hi –

On Mon, 19 Feb 2007, Jamal S. wrote:

> ```
> end
> 
> ```
> 
> \<%= end\_form\_tag %\>
> 
> why does that error happens (uninitialized constant  
> BlogController::Blog)?

Do you have a Blog model? It looks like you don’t, so the program is  
assuming that Blog is supposed to be a constant inside the scope of  
BlogCongroller – and there is no such constant, so it fails.

What’s in app/models?

David

–  
Q. What is THE Ruby book for Rails developers?  
A. RUBY FOR RAILS by David A. Black ([http://www.manning.com/black](http://www.manning.com/black))  
(See what readers are saying! [http://www.rubypal.com/r4rrevs.pdf](http://www.rubypal.com/r4rrevs.pdf))  
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?  
A. Ruby Power and Light, LLC ([http://www.rubypal.com](http://www.rubypal.com))
