Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

C:UsersMEGHA>rails new sagar_blog
      create
      create  README.rdoc
      create  Rakefile
      ... <snip> ...
Using turbolinks (2.2.1)
Using uglifier (2.5.0)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

C:UsersMEGHA>cd sagar_blog

C:UsersMEGHAsagar_blog>rails generate scaffold post title:string  body:text
      invoke  active_record
      ... <snip> ...
      create      app/assets/stylesheets/posts.css.scss
      invoke  scss
      create    app/assets/stylesheets/scaffolds.css.scss

C:UsersMEGHAsagar_blog>rails generate scaffold comment post_id:integer  body:
text
      invoke  active_record
      create    db/migrate/20140402091132_create_comments.rb
      ... <snip> ...
      invoke  scss
   identical    app/assets/stylesheets/scaffolds.css.scss

C:UsersMEGHAsagar_blog>rake db:migrate
== 20140402091036 CreatePosts: migrating ======================================
-- create_table(:posts)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

undefined method `text' for :t:SymbolC:/Users/MEGHA/sagar_blog/db/migrate/201404
02091036_create_posts.rb:6:in `block in change'
C:/Users/MEGHA/sagar_blog/db/migrate/20140402091036_create_posts.rb:3:in `change
'
C:in `migrate'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
174 views
Welcome To Ask or Share your Answers For Others

1 Answer

You called:

UsersMEGHAsagar_blog>rails generate scaffold post title:string body:text

remove the excess :

UsersMEGHAsagar_blog>rails generate scaffold post title:string body:text

is actually a hard blank, which causes the body field to be called body (with a blank before the name), this causes the migration file to generate a line t.text : body instead of t.text :body, which fails the migration (and probably later will fail other stuff as well).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...