2016-07-13 12 views
1

Ich versuche, mit einem Tutorial zum Erstellen eines Evernote-Klon zu folgen, aber in Schwierigkeiten mit diesem Abschnitt in Zeile 5, die zurück zu einem Dokument verknüpfen soll. Wenn ich versuche, es zu laufen es gibt mir ein Typeerror in Docs # Index und ‚keine implizite Konvertierung von Doc in Integer‘:Rails und href in haml

.wrapper_with_padding 
    #docs.clearfix 
     -unless @docs.blank? 
      - @docs.each do |doc| 
       %a{href: (url_for[doc])} 
        .doc 
         %p.title= link_to doc.title 
         %p.date= time_ago_in_words(doc.created_at) 
         %p.content= truncate(doc.content, length:50) 
     -else 
      %h2 Create Doc! 
      %p Start Creating Documents and Organizing Your Life! 
      %button= link_to "Create Doc", new_doc_path 
+1

Verwendung to_s Verfahren in Zeichenfolge konvertiert – uzaif

Antwort

2

Sie müssen sein, Linie ändern: 5 bis -

%a{href: (url_for(doc))} 


%a{href: (url_for[doc])} # this will give you following error 
#=> ActionView::Template::Error (can't convert Doc into Integer): 

siehe url_for

0

url_for[doc] sollte url_for(doc)