我想将“Nesta CMS应用程序”安装到Rails3应用程序上这应该是Nesta Sinatra应用程序的可能,它应该是可安装在机架上的层,但是你会怎么做? 你从哪里开始?有没有人有这方面的经验?推荐的文档?
答案 0 :(得分:5)
请注意:
http://railscasts.com/episodes/222-rack-in-rails-3
你可以在你的路线中引用Nesta,将它称为Nesta :: App(我只合并了允许你在大约一周前做到这一点的提交,所以请确保你是最新的github上的最新代码。为了完成这项工作,您需要做的就是要求Nesta的app.rb文件。
我自己还没试过Rails 3,但是我已经用Rails 2做了一段时间了。如果你有任何问题,请在邮件列表上ping我(nesta@librelist.com)。 / p>
对于想知道如何使用Rails 2.3实现相同功能的人,我一直在使用看起来像这样的代码(在lib / nesta_metal.rb中):
require File.join(File.dirname(__FILE__), *%w[.. vendor nesta app])
class NestaMetal
def initialize(app)
@app = app
end
def call(env)
status, headers, response = Nesta::App.call(env)
(status == 404) ? @app.call(env) : [status, headers, response]
end
end
干杯,
格雷厄姆
答案 1 :(得分:3)
以下是我用来在我的应用上运行的代码:
MyRailsApp::Application.routes.draw do
mount MyNestaSite.new => "/blog"
match '/' => "static#welcome" # and whatever other rails routes you want
end
当时它还需要来自github的最新版本的Sinatra,因为通过rubygems提供的版本有一个如何处理环境变量的错误,所以我将它添加到我的Gemfile中:
gem "sinatra", :git => "http://github.com/sinatra/sinatra.git"