Current location

narf Source control manager Git

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshtrom <shtrom@1991c358-8f32-0410-a49a-990740bdf4c2>2014-04-22 12:53:07 +0000
committershtrom <shtrom@1991c358-8f32-0410-a49a-990740bdf4c2>2014-04-22 12:53:07 +0000
commitdf735dd42b867297478bf3e27123200678f50279 (patch)
treef8726528f0142a62bbd10d3f55fc53e140561830
parentb5f041c3c530e1fd8a5b2707270a0540614dbc6f (diff)
Accessing wordpress users
git-svn-id: svn+ssh://scm.narf.ssji.net/svn/shtrom/scripts@1807 1991c358-8f32-0410-a49a-990740bdf4c2
-rwxr-xr-xBlogsum2WP.rb20
1 files changed, 14 insertions, 6 deletions
diff --git a/Blogsum2WP.rb b/Blogsum2WP.rb
index b00264a..d05b74d 100755
--- a/Blogsum2WP.rb
+++ b/Blogsum2WP.rb
@@ -29,7 +29,7 @@ $settings = YAML.load_file(settings_file)
# Blogsum
class Article < ActiveRecord::Base
establish_connection $settings["blogsum"]
- has_many :comment
+ has_many :comments
end
class Comment < ActiveRecord::Base
establish_connection $settings["blogsum"]
@@ -52,10 +52,11 @@ class WpPost < ActiveRecord::Base
establish_connection $settings["wordpress"]
self.primary_key = :ID
has_many :wp_postmeta, foreign_key: :post_id
- has_many :wp_comment, foreign_key: :comment_post_ID
+ has_many :wp_comments, foreign_key: :comment_post_ID
has_many :wp_term_relationships, foreign_key: :object_id
has_many :wp_term_taxonomy, through: :wp_term_relationships
- has_many :wp_term, through: :wp_term_taxonomy
+ has_many :wp_terms, through: :wp_term_taxonomy
+ belongs_to :wp_user, foreign_key: :post_author
end
class WpPostmetum < ActiveRecord::Base
establish_connection $settings["wordpress"]
@@ -78,7 +79,13 @@ class WpTermTaxonomy < ActiveRecord::Base
self.primary_key = :term_taxonomy_id
belongs_to :wp_term, foreign_key: :term_id
has_many :wp_term_relationships
- has_many :wp_post, through: :wp_term_relationships
+ has_many :wp_posts, through: :wp_term_relationships
+end
+class WpUser < ActiveRecord::Base
+ establish_connection $settings["wordpress"]
+ self.primary_key = :ID
+ has_many :wp_posts, foreign_key: :post_author
+ has_many :wp_comments
end
# Blogsum
@@ -87,6 +94,7 @@ puts Article.find(3).comment[0].comment
#Wordpress
puts WpPost.find(1).post_title
-puts WpPost.find(1).wp_comment[0].comment_content
+puts WpPost.find(1).wp_user.user_login
+puts WpPost.find(1).wp_comments[0].comment_content
puts WpPost.find(1).wp_term_taxonomy
-puts WpPost.find(7).wp_term.map {|t| "#{t.name}, "}
+puts WpPost.find(7).wp_terms.map {|t| "#{t.name}, "}