Forum: Ruby on Rails undefined method `create_table' for #<LoginController:0x5e60

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.
Naveen (Guest)
on 2006-04-19 17:00

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
Wiebe C. (Guest)
on 2006-04-19 17:17
(Received via mailing list)
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 (Guest)
on 2006-04-19 17:19
Wiebe C. 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
Alan F. (Guest)
on 2006-04-19 17:26
> 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 D. 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...

Hope this helps.

Alan
Wiebe C. (Guest)
on 2006-04-19 17:48
(Received via mailing list)
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.
Naveen (Guest)
on 2006-04-19 17:54
Wiebe C. 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.
Alan F. (Guest)
on 2006-04-19 18:08
> tell me the any sources to read more.

http://www.ruby-forum.com/topic/62687?reply_to=65793#65773
This topic is locked and can not be replied to.