2009/9/30 Preksha Patel <[email protected]>: > But now I am suffering from another problem. It stores in db but only > the first entry of XML file. I have written that code in for loop. My > code is as follow: > > @rss = FeedNormalizer::FeedNormalizer.parse open(feed_url) > @rss = @rss.entries.paginate :page => params[:page], :per_page => 5 if > [email protected]? > @abc = Abc.new > for rss in @rss.entries > if [email protected]? > �[email protected] = rss.title > �[email protected] = rss.url > end > end > @abc.save if [email protected]?
Would it be better to have the new and the save inside the loop so that you make a new one and save it for each item? At the moment you make a new object, loop round rewriting the values in @abc each time, then save it once. I presume you realise that the paginate call mean that will only get 5 at a time? Also it might be worthwhile studying the rails guide on Debugging Rails Apps at http://guides.rubyonrails.org/ The techniques there may help you to identify this sort of problem yourself. Colin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

