Forum: Ruby on Rails problem with sqlite3....

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.
Bhargavi V. (Guest)
on 2009-04-22 01:32
Hi all,

I am relatively new to ruby and RoR. I created a simple rails proj named
foo by giving command
  -> rails foo --database=sqlite3
It created a new rails proj.. So in that I created a simple db class
named user by using the below command
  -> ruby script/generate model user
so in db/migrate I got a file  named 20090421211825_create_users.rb
created.
and in app/models : user.rb got created.
in user.rb.. i have written like this

class User < ActiveRecord::Base
  validate_uniqueness :userid
  validate_presence_of :username
end

in 20090421211825_create_users.rb, its like this

class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.integer :userid
      t.string :username, :limit => 32
      t.timestamps
    end
  end

  def self.down
    drop_table :users
  end
end

after I am done... I did rake db:migrate version=20090421211825

==  CreateUsers: migrating
====================================================
-- create_table(:users)
   -> 0.0014s
==  CreateUsers: migrated (0.0018s)
===========================================

I got schema.rb in db/migrate specifying the CREATE statement of the
USER..
now, I want to see whether my table exists in the db by just giving
 -> sqlite3
 SQLite version 3.4.0
Enter ".help" for instructions
sqlite> .tables
sqlite>

I am not getting my table... I don't know whats wrong with that..Am I
looking into the correct place.... Did I do correctly??

If anyone knows, please suggest me what to do ....your response is
highly appreciated

Thanks,
Bhargavi.
Frederick C. (Guest)
on 2009-04-22 02:52
(Received via mailing list)
On Apr 21, 10:32 pm, Bhargavi V. <removed_email_address@domain.invalid>
wrote:
> looking into the correct place.... Did I do correctly??
You need to tell sqlite3 which database to look at - pass the path to
your database file as the first argument (eg sqlite3 db/
development.sqlite3 )

Fred
Bhargavi V. (Guest)
on 2009-04-22 03:22
Frederick C. wrote:
> On Apr 21, 10:32�pm, Bhargavi V. <removed_email_address@domain.invalid>
> wrote:
>> looking into the correct place.... Did I do correctly??
> You need to tell sqlite3 which database to look at - pass the path to
> your database file as the first argument (eg sqlite3 db/
> development.sqlite3 )
>
> Fred

Hi Fred,

Thanks a lot!!!! now I can see my tables... :)

Thanks,
Bhargavi.
This topic is locked and can not be replied to.