N
Newb Newb
Using Rss Parser I loaded Some Url's into the database.
All The Rss feeds has been stored in the table.
All The Rss Stories Has Been Stored In the Stories Table.
Stories Table Has Fields Like Story Name Story Description
Story Description Fields Contains Images Too...
That Story description must Not Contain Images
I want to restrict the images Not to be shown in the view.
Images has to be displayed separetely.Not Inside the Story Description
field.
I Extracted the Images and dispalyed separately using Hpricot.
But My Story Description Field Shows the Images. I don't Know How to
Restrict the Images To Be Shown..
Any Advices...
My COde Starts Here
require 'rss'
require 'open-uri'
require 'hpricot'
@feeds = Feed.findall)
@feeds.each do |f|
puts f.url
feed = RSS:arser.parse(f.url)
puts "== #{feed.channel.title} =="
puts "channel name: #{feed.channel.title}"
feed.items.each do |item|
puts "Title: #{item.title}"
puts "URL: #{item.link}"
puts "Description: #{item.description}"
@stories = Story.new
@stories.title = item.title
@stories.description = item.description
@stories.feed_id = item.id
@stories.guid = item.guid
doc = Hpricot.parse(item.description)
imgs = doc.search("//img")
@src_array = imgs.collect{|img|img.attributes["src"]}
@src_array = @src_array.to_s
@stories.picture = @src_array
@stories.save
end
end
All The Rss feeds has been stored in the table.
All The Rss Stories Has Been Stored In the Stories Table.
Stories Table Has Fields Like Story Name Story Description
Story Description Fields Contains Images Too...
That Story description must Not Contain Images
I want to restrict the images Not to be shown in the view.
Images has to be displayed separetely.Not Inside the Story Description
field.
I Extracted the Images and dispalyed separately using Hpricot.
But My Story Description Field Shows the Images. I don't Know How to
Restrict the Images To Be Shown..
Any Advices...
My COde Starts Here
require 'rss'
require 'open-uri'
require 'hpricot'
@feeds = Feed.findall)
@feeds.each do |f|
puts f.url
feed = RSS:arser.parse(f.url)
puts "== #{feed.channel.title} =="
puts "channel name: #{feed.channel.title}"
feed.items.each do |item|
puts "Title: #{item.title}"
puts "URL: #{item.link}"
puts "Description: #{item.description}"
@stories = Story.new
@stories.title = item.title
@stories.description = item.description
@stories.feed_id = item.id
@stories.guid = item.guid
doc = Hpricot.parse(item.description)
imgs = doc.search("//img")
@src_array = imgs.collect{|img|img.attributes["src"]}
@src_array = @src_array.to_s
@stories.picture = @src_array
@stories.save
end
end