On Thu, 29 Nov 2007 10:15:48 -0600, Greg D. wrote:
I had this problem once a while ago. My Ruby had sqlite version 2
support instead of version 3 or something like that. My point is it was
giving me what looked like permission errors but it was really a sqlite
version conflict. Hope that helps.
I have no idea what the problem was, but the solution was to not create
the db myself but to have the migration do it (and the rails command
create the database.yml automagically!):
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ cat sqLiteStraw.rb
require ‘fileutils’
require ‘sqlite3’
FileUtils.rmtree ‘straw’
system(“rails straw --database=sqlite3”)
FileUtils.cd(‘straw’, :verbose => true)
##############################################
system(“script/generate migration feeds”)
system(“script/generate migration categories”)
system(“script/generate migration items”)
system(“script/generate migration nodes”)
##################################################
FileUtils.rm ‘db/migrate/001_feeds.rb’, :force => true
_001_feeds = File.open(‘db/migrate/001_feeds.rb’, ‘w’)
_001_feeds.puts "
class Feeds < ActiveRecord::Migration
def self.up
create_table :feeds do |table|
table.column :title, :string
table.column :location, :string
table.column :category_id, :integer
end
end
def self.down
drop_table :feeds
end
end"
_001_feeds.close
################################################
FileUtils.rm ‘db/migrate/002_categories.rb’, :force => true
_002_categories = File.open(‘db/migrate/002_categories.rb’, ‘w’)
_002_categories.puts "
class Categories < ActiveRecord::Migration
def self.up
create_table :categories do |table|
table.column :parent_id, :integer
table.column :title, :string
end
end
def self.down
drop_table :categories
end
end"
_002_categories.close
########################################
FileUtils.rm ‘db/migrate/003_items.rb’, :force => true
_003_items = File.open(‘db/migrate/003_items.rb’, ‘w’)
_003_items.puts "
class Items < ActiveRecord::Migration
def self.up
create_table :items do |table|
table.column :title, :string
table.column :feed_id, :integer
table.column :is_read, :integer
table.column :link, :string
table.column :pub_date, :string
table.column :description, :string
end
end
def self.down
drop_table :items
end
end"
_003_items.close
########################################3
FileUtils.rm ‘db/migrate/004_nodes.rb’, :force => true
_004_nodes = File.open(‘db/migrate/004_nodes.rb’, ‘w’)
_004_nodes.puts "
class Nodes < ActiveRecord::Migration
def self.up
create_table :nodes do |table|
table.column :obj_id, :string
table.column :norder, :string
table.column :type, :string
end
end
def self.down
drop_table :nodes
end
end"
_004_nodes.close
#############################################
system(“rake db:migrate VERSION=0”)
system(“rake db:migrate”)
##########################################
system(“script/generate scaffold feed”)
system(“script/generate scaffold category”)
system(“script/generate scaffold item”)
system(“script/generate scaffold node”)
##########################################
FileUtils.rm ‘app/models/feed.rb’, :force => true
modelsFeed = File.open(‘app/models/feed.rb’, ‘w’)
modelsFeed.puts "
class Feed < ActiveRecord::Base
has_many :items
end"
modelsFeed.close
#############################################
FileUtils.rm ‘app/models/item.rb’, :force => true
modelsItem = File.open(‘app/models/item.rb’, ‘w’)
modelsItem.puts "
class Item < ActiveRecord::Base
belongs_to :feeds
end"
modelsItem.close
#############################################
puts “@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@”
puts “\t\t\thttp://localhost:3000/feeds”
puts “\t\t\thttp://localhost:3000/items”
puts “\t\t\thttp://localhost:3000/categories”
puts “\t\t\thttp://localhost:3000/nodes”
puts “@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@”
system(“script/server webrick --environment=development”)
thufir@arrakis ~/rubyCode $
-Thufir