Naveen
2006-Apr-19 13:01 UTC
[Rails] undefined method `create_table'' for #<LoginController:0x5e60
I am geeting the foolowing error. undefined method `create_table'' for #<LoginController:0x5e60110> I wrote the crete action in application controller. I am coping ther total worng please help me! class ApplicationController < ActionController::Base model :cart model :line_item before_filter :authorize def create # create_table() yields a TableDefinition instance create_table(:suppliers) do |t| t.column :name, :string, :limit => 60 # Other fields here end end def authorize unless session[:user_id] flash[:notice] = "Please log in" redirect_to(:controller => "login", :action => "login") end end private def redirect_to_index(msg = nil) flash[:notice] = msg if msg redirect_to(:action => ''index'') end end with regards, Naveen -- Posted via http://www.ruby-forum.com/.
Wiebe Cazemier
2006-Apr-19 13:16 UTC
[Rails] Re: undefined method `create_table'' for #<LoginController:0x5e60
On Wednesday 19 April 2006 15:00, Naveen wrote:> I am geeting the foolowing error. > > undefined method `create_table'' for #<LoginController:0x5e60110>(..snip..)> > def create > # create_table() yields a TableDefinition instance > create_table(:suppliers) do |t| > t.column :name, :string, :limit => 60 > # Other fields here > end >The method create_table isn''t a method of your model instances. It''s a class method. You can run it by saying: ActiveRecord::Base.connection.create_table(params)
Naveen
2006-Apr-19 13:20 UTC
[Rails] Re: undefined method `create_table'' for #<LoginController:0x
Wiebe Cazemier wrote:> On Wednesday 19 April 2006 15:00, Naveen wrote: >> I am geeting the foolowing error. >> >> undefined method `create_table'' for #<LoginController:0x5e60110> > > (..snip..) > >> >> def create >> # create_table() yields a TableDefinition instance >> create_table(:suppliers) do |t| >> t.column :name, :string, :limit => 60 >> # Other fields here >> end >> > > The method create_table isn''t a method of your model instances. It''s a > class > method. You can run it by saying: > > ActiveRecord::Base.connection.create_table(params)Thanks for Reply! Please guide me to learn ruby and rails . from where can i start bye for now -- Posted via http://www.ruby-forum.com/.
Alan Francis
2006-Apr-19 13:26 UTC
[Rails] Re: undefined method `create_table'' for #<LoginController:0x
> undefined method `create_table'' for #<LoginController:0x5e60110>The create_table method is part of the ActiveRecord migrations system and almost certainly shouldn''t be being called from a controller. I''d suggest, Naveen, that you should stop typing, and do some reading. You''re missing some fundamentals and are unlikely to pick them up from isolated messages to this list. Purchasing "Agile Web Development with Rails" would be a great start, but if cost is a problem, there are several free tutorials online covering the basics. http://www.digitalmediaminute.com/article/1816/top-ruby-on-rails-tutorials Hope this helps. Alan -- Posted via http://www.ruby-forum.com/.
Wiebe Cazemier
2006-Apr-19 13:45 UTC
[Rails] Re: undefined method `create_table'' for #<LoginController:0x
On Wednesday 19 April 2006 15:19, Naveen wrote:> Thanks for Reply! > > Please guide me to learn ruby and rails . > > from where can i start > > bye for nowAlan has given a good start. Also, what he said about that you musn''t create tables in a controller is true. I didn''t give much thought to how you were using the call, but I don''t see why you want to create tables as part of the application''s functionality.
Naveen
2006-Apr-19 13:55 UTC
[Rails] Re: undefined method `create_table'' for #<LoginController:0x
Wiebe Cazemier wrote:> On Wednesday 19 April 2006 15:19, Naveen wrote: > >> Thanks for Reply! >> >> Please guide me to learn ruby and rails . >> >> from where can i start >> >> bye for now > > Alan has given a good start. Also, what he said about that you musn''t > create > tables in a controller is true. I didn''t give much thought to how you > were > using the call, but I don''t see why you want to create tables as part of > the > application''s functionality.Where can I crete the tables, in other place how can we acees the Actioncontroll methods, I am new ro RoR Please help to use of functions of action controller, Is there any function other than these tell me the any sources to read more. -- Posted via http://www.ruby-forum.com/.