【问题标题】:Nesta CMS and Rails3 integration: menu is not workingNesta CMS 和 Rails3 集成:菜单不起作用
【发布时间】:2011-09-10 16:10:12
【问题描述】:

我已经成功地进行了一些将nesta 与rails 3 集成的实验(参见Is it possble include Nesta CMS into Rails3 application?Nesta CMS and Rails3 integration: adding blog to an exiting rails 3 application

但是,我需要博客右侧的菜单,如“Working with menus”中所述

为了试一试,我用nesta demo:content 建立了著名的内容演示站点,但是右侧出现的所有来自 content-demo/menu.txt 的链接都被破坏了,因为与主要Rails 应用程序 (http://example.com) 而不是嵌入式内斯塔博客 (http://example.com/blog)

这是我当前的文件配置,集成在 Rails 3.0.10 和 Nesta 0.9.10 之间:

config/routes.rb

  match '/blog' => Nesta::App
  match '/css/*style.css' => Nesta::App
  match '/attachments/*file' => Nesta::App
  root :to => "home#index"

更新:

使用mount Nesta::App, :at => '/blog' 代替match '/blog' => Nesta::App 得到相同的结果...

config/initializers/nesta.rb

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

nesta-blog/config/config.yml

...
content: nesta-blog/content-demo
...

我认为这取决于nesta 如何构建菜单点赞的相对路径,这取决于nesta-0.9.10/lib/nesta/app.rb 中的base_url 方法。

比我尝试在本地解包nesta-0.9.10 更改url = "http://#{request.host}" 中的url = "http://#{request.host}/blog"

  def base_url
    url = "http://#{request.host}/blog"
    request.port == 80 ? url : url + ":#{request.port}"
  end

gem 'nesta', :path => 'vendor/gems/nesta-0.9.10' 放在 Gemfile 和 build update nesta 上,但不行,不起作用。

更新:

./vendor/gems/nesta-0.9.10/lib/nesta/app.rb 中也很少尝试Nesta::Menu.for_path('/')

  def set_common_variables
    @menu_items = Nesta::Menu.for_path('/')
    @site_title = Nesta::Config.title
    set_from_config(:title, :subtitle, :google_analytics_code)
    @heading = @title
  end

没有得到结果。

我的 nesta-blog/content-demo/menu.txt 目前不指向主页(就像在默认生成中使用 nesta demo:content):

marking-up-pages
  examples/using-markdown
  examples/using-textile
  examples/using-haml
  adding-attachments
menu-editing
publishing-a-feed

如果我尝试在上面放置类似的东西:

/ or /blog or /nesta-blog 菜单消失...

所以我的问题是,它是如何工作的? 您有什么建议/解决方法吗?

提前致谢 卢卡·G·索阿夫

【问题讨论】:

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


    【解决方案1】:

    您是否尝试安装 Nesta,而不是仅匹配路线(如 Nesta CMS and Rails3 integration: adding blog to an exiting rails 3 application 中所述)?

    我希望routes.rb 中的mount 可以为您处理所有这些相对路径问题。

    我认为堆栈溢出很棒,但我怀疑在 Nesta 邮件列表中使用这些东西会做得更好。使用 Nesta 并在此处看到您的帖子的人数会相对较少...

    【讨论】:

    • 是的,我试过了。 mount Nesta::App, :at => '/blog' 的工作方式相同,在我阅读以下文章后这对我来说也很奇怪:library.edgecase.com/Rails/2011/01/04/… 但是这两种方式不会影响菜单的相对路径。此外,其他一切都很好......
    • ... 我使用 mount Nesta::App, :at => '/blog' 而不是 mount Nesta::App, :at => '/' 因为我已经有了 root :to = > "home#index" 路由主要的 Rails3 应用程序...
    猜你喜欢
    • 1970-01-01
    • 2011-04-21
    • 2012-04-27
    • 2015-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多