所以我有一个名为 development.sqlite3 的数据库,它与我的 config.rb 位于同一目录中。
当我进入 IRB 并输入以下内容时:
require 'data_mapper'
DataMapper.setup :default, "sqlite://#{Dir.pwd}/development.sqlite3"
class Post
include DataMapper::Resource
property :title, String
property :slug_url, String, :key => true
property :desc, String
property :content, Text
property :project, String
property :target_url, Text
property :trackback, Integer
property :updated_at, String
property :created_at, DateTime # A DateTime, for any date you might like.
end
DataMapper.finalize
DataMapper.auto_upgrade!
posts = Post.all
puts post.slug_url
这会像我期望的那样踢出所有 slug_urls。这是我在 config.rb 文件开头的内容。
require 'data_mapper'
require 'builder'
require 'maruku'
DataMapper.setup :default, "sqlite://#{Dir.pwd}/development.sqlite3"
class Post
include DataMapper::Resource
property :title, String
property :slug_url, String, :key => true
property :desc, String
property :content, Text
property :project, String
property :target_url, Text
property :trackback, Integer
property :updated_at, String
property :created_at, DateTime # A DateTime, for any date you might like.
end
DataMapper.finalize
DataMapper.auto_upgrade!
posts = Post.all
posts.each do |post|
page "/kw/#{post.slug_url}.haml", :proxy => "/kw/template.haml" do
@slug_url = post.slug_url
end
end
而我的 template.haml 中只有以下内容:= @slug_url
当我运行时,middleman build
我没有收到任何错误,它似乎工作正常,但它没有创建 kw 目录或它应该创建的任何文件。关于我在这里做错了什么的任何想法?