I get the same result off.png for each amigo.jid that I sent to isonline. were it should be on.png or off.png this is in the view.. <table> <tr> <th colspan="4">My Friend''s JID''s </th> </tr> <% @amigos.in_groups_of(2, false) do |grupo| %> <tr class="<%= cycle(''odd'', ''even'') -%>"> <% grupo.each do |amigo| %> <td><%= image_tag isonline(amigo.jid), :alt => "Status" %></td> <td><%= amigo.jid %></td> <% end %> </tr> <% end %> </table> this is in my helper: def isonline(amigo) @isonline = nil @online = Status.find(:all, :select => "status", :conditions => { :"collection-owner" => "#{amigo}" }) if @online == "online" @isonline = "on.png" else @isonline = "off.png" end end -- A Spectre is haunting multinational capitalism--the spectre of free information. All the powers of ``globalism'''' have entered into an unholy alliance to exorcize this spectre: Microsoft and Disney, the World Trade Organization, the United States Congress and the European Commission. Eben Moglen from the FSF. http://emoglen.law.columbia.edu/publications/dcm.html Solidarity: http://www.dailyradical.org http://www.diarioradical.org http://www.spboston.org http://www.binaryfreedom.info --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller
2008-Jun-05 08:29 UTC
Re: whats wrong here? I get the same result of each item..
This line:> @online = Status.find(:all, :select => "status", > :conditions => { :"collection-owner" => "#{amigo}" }) >will retrieve the status col from status. But @online is still an ActiveRecord object. So your condition> if @online == "online"should be if @online.status == "online -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jun-05 08:57 UTC
Re: whats wrong here? I get the same result of each item..
On Jun 5, 9:29 am, Thorsten Mueller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> This line: > > > @online = Status.find(:all, :select => "status", > > :conditions => { :"collection-owner" => "#{amigo}" }) > > will retrieve the status col from status. But @online is still > an ActiveRecord object. >Not quite :-) it''s an array. find :first is probably what is wanted. You also don''t need the quotes around amigo - :"collection-owner" => amigo would work just as well Fred> So your condition > > > if @online == "online" > > should be > > if @online.status == "online > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Hi guys, thanks, I got it to work on the console.. but when I do it from the app is not working.. it says I am sending a NIL, when I hard code a username then it works.. so it has to be the way I sent the variable from the view. <% @amigos.in_groups_of(2, false) do |grupo| %> <tr class="<%= cycle(''odd'', ''even'') -%>"> <% grupo.each do |amigo| %> <td><%= image_tag isonline(amigo.jid), :alt => "Status" %></td> <td><%= amigo.jid %></td> <% end %> </tr> <% end %> </table> whats wrong with isonline(amigo.jid) ??? amigo.jid works just fine in the next line.. Frederick Cheung wrote:> > On Jun 5, 9:29 am, Thorsten Mueller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > >> This line: >> >> >>> @online = Status.find(:all, :select => "status", >>> :conditions => { :"collection-owner" => "#{amigo}" }) >>> >> will retrieve the status col from status. But @online is still >> an ActiveRecord object. >> >> > Not quite :-) it''s an array. find :first is probably what is wanted. > You also don''t need the quotes around amigo - :"collection-owner" => > amigo would work just as well > > Fred > >> So your condition >> >> >>> if @online == "online" >>> >> should be >> >> if @online.status == "online >> -- >> Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rails Terrorist
2008-Jun-06 03:05 UTC
Re: Re: whats wrong here? I get the same result of each item
your amigo.jid is fine. but your helper isnt fine. def isonline(amigo) @isonline = nil @online = Status.find_by_collection_owner(amigo, :select => "status") if @online.status == "online" @isonline = "on.png" else @isonline = "off.png" end end please remember that you use find :all, it means that the result would be array, when you need to see the result of each array you should describe index key like @online[0] or @online[1] like that. Look your code :> @online = Status.find(:all, :select => "status", > :conditions => { :"collection-owner" => "#{amigo}" }) >the result would be @online[0].status, please understand carefully find :all is diferent with find(id) <-- it will show you hashing. Reinhart http://teapoci.blogspot.com -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rails Terrorist wrote:> your amigo.jid is fine. but your helper isnt fine. > > > def isonline(amigo) > @isonline = nil > @online = Status.find_by_collection_owner(amigo, :select => > "status") > > if @online.status == "online" > @isonline = "on.png" > else > @isonline = "off.png" > end > > end > > > > please remember that you use find :all, it means that the result would > be array, when you need to see the result of each array you should > describe index key like @online[0] or @online[1] like that. Look your > code : > > >> @online = Status.find(:all, :select => "status", >> :conditions => { :"collection-owner" => "#{amigo}" }) >> >> > > the result would be @online[0].status, please understand carefully find > :all is diferent with find(id) <-- it will show you hashing. > > Reinhart > http://teapoci.blogspot.com >Hi, yes I know I did changed my helper.. this is what I have now.. I also added just now to check for nil in case some records have problems.. module RosteritemsHelper def isonline(amigo) @online = Status.find(:first, :select => "status", :conditions => { :"collection-owner" => amigo }) unless @online.nil? if @online.status == "online" @isonline = "on.png" else @isonline = "off.png" end end end end --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rails Terrorist
2008-Jun-06 06:35 UTC
Re: whats wrong here? I get the same result of each item
I tested your script like below and it works : module RosteritemsHelper def isonline(amigo) @online = Status.find(:first, :select => "status", :conditions => { :"collection-owner" => amigo }) if @online != nil && @online.status == "online" @isonline = "on.png" else @isonline = "off.png" end end Remember to save both of your image in /public/images. I tested script above and really working fine. Reinhart http://teapoci.blogspot.com -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---