Reputation: 3105
I've been working on a Rails app to conglomerate directories pulled from IPFS. For some reason, app/views/layouts/application.html.erb
isn't rendering.
Each IPFS entry has a corresoponding ActiveRecord model. The relevant parts of routes.rb
are:
Rails.application.routes.draw do
resources :entries, path: :e, constraints: { id: /.*/ }
root 'entries#index'
end
The index
action of EntriesController
is:
class EntriesController < ApplicationController
def index
@entries = @space.roots
end
end
My application.html.erb
is:
<!DOCTYPE html>
<html>
<head>
<title>Tip</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<% if notice %>
<p class="alert alert-success"><%= notice %></p>
<% end %>
<% if alert %>
<p class="alert alert-danger"><%= alert %></p>
<% end %>
<%= yield %>
</body>
</html>
Upvotes: 0
Views: 39
Reputation: 2883
I cloned your code, ran it locally, debugged and made a few tests.
Turns out that the blame is on the initialize of the controller, if you change it to this, it works:
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? && [email protected]?(@entry)
@space.roots << @entry
end
end
if @entry.kind_of?(Blob)
send_data @entry.content, type: 'text/html', disposition: 'inline'
end
end
end
Upvotes: 1