so i did create 'Archive' module .
module Archive
def self.included(klass)
klass.instance_eval do
define_method "save_#{klass.name}_archive" do
ArchiveLogs.debug("PASS HERE")
self.becomes "Arch#{klass.name}".constantize
end
end
end
end
and i use it just here :
ArchiveLogs.debug("DEV BEGIN")
ArchiveLogs.debug("DEV inspect content"+content.inspect)
archived_content = content.save_Content_archive
ArchiveLogs.debug("DEV inspect archived"+archived_content.inspect)
test = archived_content.save
test2 = archived_content.save!
ArchiveLogs.debug("DEV WORK ?"+test.inspect)
ArchiveLogs.debug("DEV WORK 2?"+test2.inspect)
and here are my logs
DEV BEGIN
DEV inspect content#<Content id: 1653768, server_path:
"20141219/M2014121900660", server_name: "content.html", is_html: 1,
checksum: #<BigDecimal:62433c0,'0.1307989417E10',18(27)>, save_date:
nil, save_place: nil, user_id: nil, created_at: "2015-03-31 11:29:43",
updated_at: "2015-03-31 11:29:43", ts_content: nil>
PASS HERE
DEV inspect archived#<ArchContent id: 1653768, server_path:
"20141219/M2014121900660", server_name: "content.html", is_html: 1,
checksum: #<BigDecimal:624a9e0,'0.1307989417E10',18(27)>, save_date:
nil, save_place: nil, user_id: nil, created_at: "2015-03-31 11:29:43",
updated_at: "2015-03-31 11:29:43", ts_content: nil>
DEV WORK ?true
DEV WORK 2?true
content model :
class Content < ActiveRecord::Base
has_many :information
attr_accessor :text_content
include Archive
.
.
.#many methods here
.
.
end
Arch content model :
class ArchContent < ActiveRecord::Base
set_table_name 'archive.contents'
has_many :information, :class_name => 'ArchInformation',foreign_key:
'content_id'
include Archive
.
.
.#many methods here
.
.
end
as you see , my Archive module does his job. Creating ArchContent object
when i give him Content object.
But here is my problem .save return true , but my archived_content isn't
store in my database. Why ?
how
to debug this ? Any help apricieted !
--
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/89bf6fb6addd2afbe0dc5a9b7e5711f4%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment