Did u add these attributes in post.rb as attr_accesble

On Monday, 6 April 2015 23:30:30 UTC+4, Ruby-Forum.com User wrote:
>
> 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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/d1fd52a7-09de-4e90-91a4-71c9eef63b23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to