Forum: Ruby on Rails simpel question (scaffold?) :(

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jamal S. (Guest)
on 2007-02-14 01:33
Hello their,

Its very simple, here is my code:

class BlogController < ActionController::Base
   scaffold :blogs
end

When I go to
http://127.0.0.1:3000/blog/list/

I get this error:
uninitialized constant Blog

The table exist (blogs), but it doesn't allow me to use the default
scaffold interface, why?

Please any help, thanks :)

Regards,
Jamal
Guest (Guest)
on 2007-02-14 01:36

Just scaffold :blog, not :blogs
Jamal S. (Guest)
on 2007-02-14 01:38
Guest wrote:
>
>
> Just scaffold :blog, not :blogs

Thanks for answering me so fast :D

I just tried this, and still the error message didn't change :( ?
Jamal S. (Guest)
on 2007-02-14 02:04
Jamal S. wrote:
> Hello their,
>
> Its very simple, here is my code:
>
> class BlogController < ActionController::Base
>    scaffold :blogs
> end
>
> When I go to
> http://127.0.0.1:3000/blog/list/
>
> I get this error:
> uninitialized constant Blog
>
> The table exist (blogs), but it doesn't allow me to use the default
> scaffold interface, why?
>
> Please any help, thanks :)
>
> Regards,
> Jamal

I get it to work, if you had the same error, then you must remember that
to set the table name in a model.

ruby script/generate model blog

then open the file blog.rb
class Blog < ActiveRecord::Base
  set_table_name "blogs"
end


then go back to your controller:
class BlogController < ApplicationController
  scaffold :blog;

end

Everything work :D

-Never give up!
This topic is locked and can not be replied to.