是否可以将 Nesta CMS 包含到 Rails3 应用程序中?

发布于 2024-09-26 09:28:27 字数 122 浏览 4 评论 0原文

我想将 Nesta CMS 应用程序“安装”到 Rails3 应用程序上 这可能是 Nesta Sinatra 应用程序的原因,它应该是机架可安装层,...但是您会怎么做? 你将从哪里开始?有人有关于这个话题的经验吗?建议的文档?

I'd like "to mount" a Nesta CMS app onto a Rails3 app This should be possible couse of being Nesta a Sinatra app, which should be a Rack mountable layer, ... but how would you do it ?
Where will you start from ? Does anybody has experiences on this topic ? Suggested docs ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

唔猫 2024-10-03 09:28:27

嘿卢卡。我一两个月以来一直想写这篇文章。您只需使用 Rails Metal 将 Nesta 安装为 Rack 应用程序即可。

观看此内容:

http://railscasts.com/episodes/222-rack -in-rails-3

您将能够在路线中通过将其称为 Nesta::App 来引用 Nesta(我大约一周前才将允许您执行此操作的提交合并到 master 中) ,因此请确保您掌握了 github 上的最新代码)。为了实现这一点,您所需要做的就是需要 Nesta 的 app.rb 文件。

我自己还没有在 Rails 3 上尝试过这一点,但我已经在 Rails 2 上尝试了一段时间了。如果您遇到任何问题,请在邮件列表上联系我 ([电子邮件受保护])。

对于想知道如何使用 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

干杯,

Graham

Hey Luca. I've been meaning to write this up a for a month or two. You just need to mount Nesta as a Rack app, using Rails Metal.

Have a watch of this:

http://railscasts.com/episodes/222-rack-in-rails-3

You'll be able to refer to Nesta in your routes by referring to it as Nesta::App (I only merged the commit that allows you to do this into master a week or so ago, so make sure you're up to date with the latest code on github). In order to make that work, all you should need to do is to require Nesta's app.rb file.

I'm yet to try this with Rails 3 myself, but I've been doing it for a while with Rails 2. If you have any trouble, ping me on the mailing list ([email protected]).

For people wondering how to achieve the same thing with Rails 2.3, I've been using code that looks like this (in 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

Cheers,

Graham

败给现实 2024-10-03 09:28:27

这是我用来让它在我的应用程序上工作的代码:

MyRailsApp::Application.routes.draw do
  mount MyNestaSite.new => "/blog"
  match '/' => "static#welcome" # and whatever other rails routes you want
end

当时它还需要 github 上的最新版本的 Sinatra,因为通过 ruby​​gems 提供的版本在处理环境变量的方式上有一个错误,所以我将其添加到我的 Gemfile 中:

gem "sinatra", :git => "http://github.com/sinatra/sinatra.git"

Here's the code I used to make it work on my app:

MyRailsApp::Application.routes.draw do
  mount MyNestaSite.new => "/blog"
  match '/' => "static#welcome" # and whatever other rails routes you want
end

At the time it also required the latest version of Sinatra from github as the version available via rubygems had a bug in how it handled environment variables, so I added this to my Gemfile:

gem "sinatra", :git => "http://github.com/sinatra/sinatra.git"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文