Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1100389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:52:24+00:00 2026-05-17T00:52:24+00:00

I am not able to create database columns when i use t.string or t.number.

  • 0

I am not able to create database columns when i use t.string or t.number.

When i did rake db:migrate i got this

C:\Ruby\joker\chapter3>rake db:migrate
(in C:/Ruby/joker/chapter3)
==  CreateComicBooks: migrating ===============================================
-- create_table(:comic_books)
   -> 0.0630s
==  CreateComicBooks: migrated (0.0640s) ======================================

I have used the following code

class ComicBook < ActiveRecord::Base
def self.up
create_table :comic_books do |t|
t.string :title
t.string :writer
t.string :artist
t.integer :issue
t.string :publisher
t.timestamps
end
end

def self.down
    drop_table :comic_books
    end
end

I also tried with

class ComicBook < ActiveRecord::Base
def self.up
create_table :comic_books do |t|
t.column "title", :string
t.column "writer", :string
t.column "artist", :string
t.column "issue", :number
t.column "publisher", :string
t.timestamps
end
end

def self.down
# called when a migration is reversed
    drop_table :comic_books
    end
end

In the database I am getting the following output

mysql> show tables;
+-----------------------------------+
| Tables_in_comic_books_development |
+-----------------------------------+
| comic_books                       |
| schema_migrations                 |
+-----------------------------------+
2 rows in set (0.00 sec)

mysql> describe comic_books;
+------------+----------+------+-----+---------+----------------+
| Field      | Type     | Null | Key | Default | Extra          |
+------------+----------+------+-----+---------+----------------+
| id         | int(11)  | NO   | PRI | NULL    | auto_increment |
| created_at | datetime | YES  |     | NULL    |                |
| updated_at | datetime | YES  |     | NULL    |                |
+------------+----------+------+-----+---------+----------------+
3 rows in set (0.01 sec)

mysql>

Now when i am trying to create a new record i am getting this

C:\Ruby\joker\chapter3>ruby script/console
Loading development environment (Rails 2.3.8)
>> mycb = ComicBook.new
=> #<ComicBook id: nil, created_at: nil, updated_at: nil>
>> mycb.title = 'All new'
NoMethodError: undefined method `title=' for #<ComicBook id: nil, created_at: ni
l, updated_at: nil>
        from C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record
/attribute_methods.rb:259:in `method_missing'
        from (irb):2

I think its a very small error but I just cant figure it out.

Looking forward for your help and support.

Thank You

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:52:25+00:00Added an answer on May 17, 2026 at 12:52 am

    What’s this line at the top of your migration? Is that just an error in your question ?

    ComicBook < ActiveRecord::Base
    

    It looks like your put the code in the model instead of in your migration!?

    Look in /db/migrate folder for the file which should have something like this at the top

    class CreateComicBooks < ActiveRecord::Migration
    

    It looks like you’ve used a generator to create the migration (which is fine) then run a rake db:migrate and that will explain why you have the table in the db with just the id and timestamps. You probably want to to run rake db:rollback then add your fields into the def self.up part in the migration and re-migrate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not able to create a jsTree inside of a jQuery UI tab.
In my windows 2003 box, I am not able to create new web applications.
I am trying to create virtual desktop. I complete successfully.But i am not able
I am trying to create a customized UISearchBar. I am not able to find
not able to get this, can someone help for this LINQ query? select col1,
Im not able to load the page with circlepageindicator. This is the xml <FrameLayout
I’m not sure how to use Java/JDBC to insert a very long string into
Hey guys I am doing a Database Manager proyect and I am not able
I have managed to create a connection to the database and am able to
I have this table CREATE TABLE IF NOT EXISTS `profile_connections` ( `id` int(11) NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.