我一直在研究Rails app to conglomerate directories pulled from IPFS。出于某种原因,app/views/layouts/application.html.erb
isn't rendering。
每个IPFS条目都有一个相应的ActiveRecord模型。 routes.rb
的相关部分是:
Rails.application.routes.draw do
resources :entries, path: :e, constraints: { id: /.*/ }
root 'entries#index'
end
index
的{{1}}操作是:
EntriesController
我的class EntriesController < ApplicationController
def index
@entries = @space.roots
end
end
是:
application.html.erb
答案 0 :(得分:1)
我克隆了你的代码,在本地运行,调试并做了一些测试。
事实证明,责任在于控制器的初始化,如果将其更改为此,它可以正常工作:
class EntriesController < ApplicationController
# def initialize(*args)
# @space = Space.first_or_create()
# end
def index
@entries = Space.first_or_create().roots
end
def show
id = params[:id]
if id.start_with?('.../')
@entry = @space.lookup(id)
else
@hash = id
@entry = Entry.find_or_create_by(code: @hash)
if @entry.parents.empty? && !@space.roots.include?(@entry)
@space.roots << @entry
end
end
if @entry.kind_of?(Blob)
send_data @entry.content, type: 'text/html', disposition: 'inline'
end
end
end