本文介绍了是否可以将Nesta CMS包含在Rails3应用程序中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Nesta CMS应用程序安装"到Rails3应用程序上这可能是因为Nesta是Sinatra应用程序,应该是可以在机架上安装的层,但是,您将如何做呢?您将从哪里开始?有人对此主题有经验吗?建议的文档?

解决方案

卢卡.我一直想写一个或两个月的时间.您只需要使用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上进行了一段时间.如果遇到任何问题,请在邮件列表([email protected])上ping我./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

干杯

格雷厄姆

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 ?

解决方案

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

这篇关于是否可以将Nesta CMS包含在Rails3应用程序中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 06:32