2017-03-17 2 views
0

Ich habe an einem Rails app to conglomerate directories pulled from IPFS gearbeitet. Aus irgendeinem Grund, app/views/layouts/application.html.erbisn't rendering.Warum werden meine Assets nicht in Rails 4 gerendert?

Jeder IPFS-Eintrag verfügt über ein entsprechendes ActiveRecord-Modell. Die relevanten Teile routes.rb sind:

Rails.application.routes.draw do 
    resources :entries, path: :e, constraints: { id: /.*/ } 
    root 'entries#index' 
end 

Die index Wirkung von EntriesController ist:

class EntriesController < ApplicationController 
    def index 
    @entries = @space.roots 
    end 
end 

Mein application.html.erb ist:

<!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> 

Antwort

1

ich Ihren Code geklont, lief es lokal, debuggt und machte ein paar Tests.

Es stellte sich heraus, dass die Schuld auf den Initialisierungsvorgang des Controllers ist, wenn Sie es dies zu ändern, es funktioniert:

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 
+0

ich die Super-Klasse Konstruktor aufzurufen benötigt. Danke, dass Sie mir geholfen haben, es zu finden. Ich war benommen. – Will

Verwandte Themen