Question

ok this is prob something very easy and im prob doing something very wrong.. I have not played with rails in 2-3 years.

but like the topic says. I get the results on the terminal(linux xterm) output of a "rails s"

result:

    Started GET "/rssfeeds/1" for 127.0.0.1 at 2014-05-14 04:10:45 -0400
Processing by RssfeedsController#show as HTML
  Parameters: {"id"=>"1"}
  Rssfeed Load (2.7ms)  SELECT  "rssfeeds".* FROM "rssfeeds"  WHERE "rssfeeds"."id" = ? LIMIT 1  [["id", 1]]
HakTip 97 – NMap 101: Advanced Scanning Techniques
http://hak5.org/episodes/haktip-97
Hak5 1612 – Drone Basics and Open Source Ship Tracking
http://hak5.org/episodes/hak5-1612
HakTip 96 – NMap 101: Discovery Options Part 2
http://hak5.org/episodes/haktip-96
Hak5 1611 – Open Source Drones and Android SDR
http://hak5.org/episodes/hak5-1611
HakTip 95 – NMap 101: Scanning Networks Using Alternative Packets
http://hak5.org/episodes/haktip-95
Hak5 1610 – Identify And Locate Ships Via AIS Transmissions!
http://hak5.org/episodes/hak5-1610
Hak5 1609 – Tracking Aircraft over 300 miles away! Mountain + Drone + SDR
http://hak5.org/episodes/hak5-1609
Pivoting In Metasploit – Metasploit Minute
http://hak5.org/episodes/metasploit-minute/pivoting-in-metasploit-metasploit-minute
HakTip 94 – NMap 101: Scanning Networks For Open Ports To Access
http://hak5.org/episodes/haktip-94
Hak5 1608 – The Earth is ROUND! All about Radio Horizon
http://hak5.org/episodes/hak5-1608
Linux Persistance – Metasploit Minute
http://hak5.org/episodes/metasploit-minute/linux-persistance-metasploit-minute
  Rendered rssfeeds/_feed.html.erb (1.3ms)
  Rendered rssfeeds/show.html.erb within layouts/application (43.8ms)
Completed 200 OK in 963ms (Views: 544.4ms | ActiveRecord: 2.7ms)

but of course I need that to render on the view..

here is my method in the controller:

 def show
    unless @rssfeed.url.nil?
      @feeds = Feedjira::Feed.fetch_and_parse(@rssfeed.url)
    end
  end

here is my view (show.html.erb) that is the default and I added a render to call a _feed.html.erb file.

<p id="notice"><%= notice %></p>

<p>
  <strong>Name:</strong>
  <%= @rssfeed.name %>
</p>

<p>
  <strong>Url:</strong>
  <%= @rssfeed.url %>
</p>


<%= render 'feed' %>


<%= link_to 'Edit', edit_rssfeed_path(@rssfeed) %> |
<%= link_to 'Back', rssfeeds_path %>

ok here is the last part: where is supposed to happen(file _feed.html.erb)

<ul>
<% @feeds.entries.each do |line| %>
        <li> <%= puts line.title %> <%= puts line.url %> </li>
<% end %>
</ul>

any ideas? I had this happen to me before when in my view I had something different than in my controller like the method name will not be the same of my view.. but I have double check and as far I can see is all ok.

Was it helpful?

Solution

remove puts from the file file _feed.html.erb
puts print the output in the console and nil gets returned which in turn gets printed on the page, thats why no output.

<ul>
<% @feeds.entries.each do |line| %>
        <li> <%= puts line.title %> <%= puts line.url %> </li>
<% end %>
</ul>

to

<ul>
<% @feeds.entries.each do |line| %>
        <li> <%= line.title %> <%=  line.url %> </li>
<% end %>
</ul>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top