Nesta CMS和Grails 3集成:将博客添加到现有的rails 3应用程序中

时间:2011-08-23 20:24:10

标签: ruby-on-rails ruby ruby-on-rails-3 content-management-system nestacms

我将nesta(0.9.8)cms添加到现有的Rails 3.0.10应用程序中。我启动并运行了博客,但没有布局/样式表。

我到目前为止所做的是:  1.在rails应用主根内部,添加gem'natea',gem'sass'并运行     “捆绑”
 2.运行“nesta new nesta-blog”  3.编辑config.ru如下:

require ::File.expand_path('../config/environment',  __FILE__)
map "/" do
 run MyRails3App::Application
end

require 'nesta/env'
require 'nesta/app'

Nesta::App.root = ::File.expand_path('./nesta-blog', ::File.dirname(__FILE__))
map "/blog" do
 run Nesta::App
end

4。编辑config / routes.rb如下:

require 'nesta/env'
require 'nesta/app'

Rails3MongoidOmniauthSimple::Application.routes.draw do

 mount Nesta::App.new => "/blog"
 root :to => "home#index"
...

5。 cd nesta-blog  6.运行nesta demo:content

现在,如果您从〜/ main-rails-app运行rails s,转到http://localhost:3000/blog您将看到示例nesta网站但没有他的默认布局/样式表,而如果您运行来自〜/ main-rails-app / nesta-blog内部的shotgun config.ru,转到http://localhost:9393/一切都正确显示。

有什么建议吗?

提前致谢 Luca G. Soave

1 个答案:

答案 0 :(得分:1)

我还没有达到我想要的即插即用级别,但我在我的Rails 3.0网站上运行Nesta,将其添加到config / routes.rb:

mount Nesta::App, :at => '/'
match '/css/*style.css' => Nesta::App
match '/attachments/*file' => Nesta::App

我还没有考虑过这样做的更简洁的方法(即避免必须指定css和附件路线)。

我在位于“#{Rails.root} / nesta”的目录中创建了我的Nesta应用程序。我还需要一个config / initializers / nesta.rb:

require "nesta/env"
Nesta::Env.root = ::File.expand_path("../../nesta",
                                     File.dirname(__FILE__))

我非常喜欢你这样做的方式。