Ruby on Rails Monday, April 6, 2015

Hi all,
I am not been able to insert row into DB from the rails console.

Command used:
Post.create(:title =>"t1",:content =>"c1")

Output :
(0.2ms) begin transaction
SQL (0.4ms) INSERT INTO "posts" ("created_at", "updated_at") VALUES
(?, ?) [["created_at", "2015-04-06 19:21:40.219007"], ["updated_at",
"2015-04-06 19:21:40.219007"]]
(204.6ms) commit transaction
=> #<Post id: 13, title: nil, content: nil, created_at: "2015-04-06
19:21:40", updated_at: "2015-04-06 19:21:40">

title and content column are not populates.

create_posts.rb file :

class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.string :title
t.text :content

t.timestamps null: false
end
end
end

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/17ceeb0b4066ce4f668d5991a68d821d%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment