Hi everybody.. I''m stuck with a strange (stupid) problem I can''t understand. I''m trying to do this in the articles_controller: def updatecollection @arts = Article.find_by_solr("14 MAY 91").results @arts.each do |doc| @sub = doc.title[15,150] # Updating one record: doc.title = @sub doc.save end end It loads but i doesn''t update the article..the strange fact is that if I do the same process for a single doc in the console it works.. so what''s wrong? something in the .each do? thanks! (any different solution it''s fine for me ;) ) -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2010/1/25 adedip <adedip-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Hi everybody.. I''m stuck with a strange (stupid) problem I can''t > understand. > > I''m trying to do this in the articles_controller: > > def updatecollection > @arts = Article.find_by_solr("14 MAY 91").results > > -hBx8LNrgDMbtRgLqZ5aouw@public.gmane.org do |doc| > @sub = doc.title[15,150] > # Updating one record: > doc.title = @sub > doc.saveTest the return value from save here to see if it succeeded. Perhaps it is failing validation. Colin> > end > end > > It loads but i doesn''t update the article..the strange fact is that if > I do the same process for a single doc in the console it works.. so > what''s wrong? something in the .each do? > thanks! > > (any different solution it''s fine for me ;) ) > > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
My Guess is that try eliminating the results @arts = Article.find_by_solr("14 MAY 91").results from this and try using @arts = Article.find_by_solr("14 MAY 91") -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 25 Gen, 16:57, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> 2010/1/25 adedip <ade...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > Hi everybody.. I''m stuck with a strange (stupid) problem I can''t > > understand. > > > I''m trying to do this in the articles_controller: > > > def updatecollection > > @arts = Article.find_by_solr("14 MAY 91").results > > > -hBx8LNrgDMbtRgLqZ5aouw@public.gmane.org do |doc| > > @sub = doc.title[15,150] > > # Updating one record: > > doc.title = @sub > > doc.save > > Test the return value from save here to see if it succeeded. Perhaps > it is failing validation. > > Colinbut I get true doing it on console...could it be different on the app controller? anyway how do i test it? something like: if doc.save puts "true" ? thx> > > > > end > > end > > > It loads but i doesn''t update the article..the strange fact is that if > > I do the same process for a single doc in the console it works.. so > > what''s wrong? something in the .each do? > > thanks! > > > (any different solution it''s fine for me ;) ) > > > -- > > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2010/1/25 adedip <adedip-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> On 25 Gen, 16:57, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> 2010/1/25 adedip <ade...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> >> > Hi everybody.. I''m stuck with a strange (stupid) problem I can''t >> > understand. >> >> > I''m trying to do this in the articles_controller: >> >> > def updatecollection >> > @arts = Article.find_by_solr("14 MAY 91").results >> >> > -hBx8LNrgDMbtRgLqZ5aouw@public.gmane.org do |doc| >> > @sub = doc.title[15,150] >> > # Updating one record: >> > doc.title = @sub >> > doc.save >> >> Test the return value from save here to see if it succeeded. Perhaps >> it is failing validation. >> >> Colin > > but I get true doing it on console...could it be different on the app > controller? > anyway how do i test it? something like: > > if doc.save > puts "true"No, have a look at the Rails Guide on debugging. There are various options, I would use ruby-debug and break in at that point. 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.