Hello, This is a method that I have written to show personal messages. If the message that is requested is sent "to" the logged in user I will do another check and set status to opened if necessary. I can''t figure out why the last "else" statement never executes if the first one is false: Message.find(params[:id], :conditions => {:from ) def show if @message = Message.find(params[:id], :conditions => {:to => @user.id }) then if @message.status = "new" @message.status = "opened" @message.save end else @message = Message.find(params[:id], :conditions => {:from => @user.id }) end rescue ActiveRecord::RecordNotFound end Best regards. Asbjørn Morell. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> if @message = Message.find(params[:id], :conditions => {:to => > @user.id }) thencause what you do here is assigning the searchresult to @message if @message == Message.find(params[:id],... i''m not sure right now, if this would work, this would depend on what''s in @message. the name implies a string/text, which you can''t compare with an active record object anyway maybe what you want to do is something like: if @message == Message.find(params[:id],...).field_name to compare with the data stored in field_name or @message contains a record, but then objects are not necessarily identical, if they have the same content. maybe you would have to use another way to compare them like the eql? function -- 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 -~----------~----~----~----~------~----~------~--~---
atmorell wrote:> if @message.status = "new"if @message.status == "new" your version is always true! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---