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'') %> <dl> <dt>Title</dt> <dd><%= text_field "blog", "title", "size" => 20 %></dd> <dt>Comments</dt> <dd><textarea cols="25" id="blog_comment" name="blog[comment]" rows="10"></textarea></dd> <dt></dt> <dd><%= submit_tag("Add New Title") %></dd> </dl> <%= end_form_tag %> why does that error happens (uninitialized constant BlogController::Blog)? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2007-Feb-19 14:57 UTC
Re: whats this error (uninitialized constant) ?
Hi -- On Mon, 19 Feb 2007, Jamal Soueidan wrote:> > 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'') %> > > <dl> > > <dt>Title</dt> > <dd><%= text_field "blog", "title", "size" => 20 %></dd> > > <dt>Comments</dt> > <dd><textarea cols="25" id="blog_comment" name="blog[comment]" > rows="10"></textarea></dd> > > <dt></dt> > <dd><%= submit_tag("Add New Title") %></dd> > > </dl> > > <%= 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) (See what readers are saying! 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) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---