2017-02-03 3 views
0

私はブログアプリ(octopress)でアプリを基づかてきた次のガイドに、submoduled:シナトラとRails - submoduledアプリを起動

http://www.nickhammond.com/setting-octopress-jekyll-blog-rails-application/

それは少し古くなったが以外ですいくつかの宝石の周りを変えなければならないとうまくいくようです。ガイドは、あなたのメインの親appディレクトリ内の「ブログ」と呼ばれるフォルダ内の小さなアプリの命を持つ示唆しています。ここでは、config.ruファイルを変更して、run.rbに名前を変更するように指示されました。以下のようにファイルがある:次のように私の親アプリで

/blog/run.rb

require 'bundler/setup' 
require 'sinatra/base' 

# The project root directory 
$root = ::File.dirname(__FILE__) 

class Blog < Sinatra::Base 

    get(/.+/) do 
    send_sinatra_file(request.path) {404} 
    end 

    not_found do 
    send_file(File.join(File.dirname(__FILE__), 'public', '404.html'), {:status => 404}) 
    end 

    def send_sinatra_file(path, &missing_file_block) 
    file_path = File.join(File.dirname(__FILE__), 'public', path) 
    file_path = File.join(file_path, 'index.html') unless file_path =~ /\.[a-z]+$/i 
    File.exist?(file_path) ? send_file(file_path) : missing_file_block.call 
    end 

end 

マイconfig.ruファイルは次のとおりです。

/config.ru

# This file is used by Rack-based servers to start the application. 

require ::File.expand_path('../config/environment', __FILE__) 
require './blog/run' 

# Action Cable requires that all classes are loaded in advance 
Rails.application.eager_load! 

map '/' do 
    run Rails.application 
end 

map '/blog' do 
    run Blog 
end 

は私がlocalhostの訪問時:3000 /ブログを、私はルートが見つからないというエラーを得ることはありません、しかし受け取る:

This localhost page can’t be found 

No web page was found for the web address: http://localhost:3000/blog 

適切に私のconfig.ruファイルを設定する方法上の任意のヘルプは大幅に、事前に感謝をいただければ幸いです。

答えて

0

routes.rbをし

require '/blog/run' 


map '/blog' do 
    run Blog 
end 

を移動し、このことができますかどうかを確認してみてください。

更新:(終わりに、それはこれにあなたのconfig.ruを変更しました)。

require ::File.expand_path('../config/environment', __FILE__) 
require './blog/run' # Require the run.rb file that we created earlier which has the Rack setup for the blog 

map '/' do # By default we want everything to hit our Rails application 
    run Rails::Application 
end 

map '/blog' do # Anything at blog/ and beyond will then hit the blog 
    run Blog 
end 

これを試してください。

+0

ルート方法内側に配置すると、エラーを与える: #ための未定義のメソッド 'マップ」(NoMethodError) 及び方法外側にも同様のものを与えます。 – Mark

+0

@マーク最新の投稿を読んでこのステップを試してみてください。何か誤りがある場合は教えてください。ヘルプを試すために時間を割いて、すべての感謝の – EVX

+0

初。 3000 /ブログ私は同じエラーに、いいえWebページを取得していない:私はRails.application.eager_loadマイナス前にそれを持っていたものを見ることができます!、私はローカルホストにnagivateしようとする限りは、あなたの提案を、試してみましたhttp:// localhost:3000/blog – Mark