Permalink
Browse files

started adding database integration

  • Loading branch information...
1 parent f89462b commit 32d0ed5e0c8b80271c0b3b504b0b5e45678961c1 @elentok committed Jan 6, 2012
Showing with 36 additions and 3 deletions.
  1. +3 −0 ep.rb
  2. +7 −0 lib/db/db.rb
  3. +19 −0 lib/db/migration1.rb
  4. +2 −3 lib/epguides.rb
  5. +5 −0 lib/models/episode.rb
View
3 ep.rb
@@ -0,0 +1,3 @@
+require_relative 'lib/epguides'
+
+
View
@@ -0,0 +1,7 @@
+require 'rubygems'
+require 'active_record'
+
+ActiveRecord::Base.establish_connection(
+ adapter: 'sqlite3',
+ database: 'epguides.sqlite3'
+)
View
@@ -0,0 +1,19 @@
+require_relative 'db'
+
+class Migration1 < ActiveRecord::Migration
+ def self.up
+ create_table :episodes do |t|
+ t.string :title
+ t.integer :season
+ t.integer :number
+ t.date :date
+ end
+ end
+
+ def self.down
+ drop_table :episodes
+
+ end
+end
+
+Migration1.new.migrate :up
View
@@ -4,6 +4,8 @@
require 'open-uri'
require 'nokogiri'
+require_relative 'models/episode'
+
GoogleAjax.referrer = 'elentok.com'
class EpGuides
@@ -62,6 +64,3 @@ class ShowResult
attr_accessor :title, :url, :cache_url, :epguides_id
end
-class Episode
- attr_accessor :season, :number, :title, :date
-end
View
@@ -0,0 +1,5 @@
+require 'active_record'
+
+class Episode < ActiveRecord::Base
+ validates :season, :number, :title, :date, presence: true
+end

0 comments on commit 32d0ed5

Please sign in to comment.