开发者

Why this Ruby query

I'm trying to create an object with this data. Problem is that as you see in code it isn't saving the data I'm giving nor the specified Id. Any ideas?

>> Attachment.create(:id => 50, :attachment_file_name => "tumblr_lbxifqK2LT1qa0qyy.jpg",  
:attachment_content_type  => "image/jpeg", :attachment_file_size=>80960, 
:attachment_updated_at => "2010-12-22 07:39:01", :created_at => "2010-12-22 07:39:02", 
:updated_at => "2011-03-07 02:14:05", :post_id => nil, :about_me => nil, :is_nsfw => nil, 
:attachable_id => nil, :attachable_type => nil, :is_default => nil, :temp_token => nil, 
:user_id => 1, :description => nil, :visits => nil)

=> #<Attachment id: 451, shortcut: "cjke", attachment_file_name: nil, 
attachment_content_type: nil, attachment_file_size: nil, attachment_updated_at: nil, 
created_at: "2011-03-07 04:46:15", updated_at: "2011-03-07 04:46:15", post_id: nil, 
about_me: nil, is_nsfw: nil, attachable_id: nil, attachable_type: nil, is_default: nil, 
temp_token: nil, user_id: 1, description: nil, visits: nil>

开发者_C百科

UPDATED: It's saving the username. Seems like what is not saving is the related paperclip info and the specified ID.


id is a protected attribute when dealing with ActiveRecord and Rails; you can't assign it a value manually.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜