Well, I''ve been testing out my code in production mode, in anticipation of being able to show off my site soon. Unfortunately, all is not going as expected. Production mode... well, its behaving differently than development did. I''ve already had login validation issues, and now it seems that my PM system is broken. If a user enters a non-existent username as a recipient of a message, I now get a 500 internal server error. In the log, I get: TypeError (can''t modify frozen hash) at line 108. Line 108 is "@message.sender find_user_and_messages.get_user_id.to_s", which shouldn''t even be executing (its also a poorly named method, but thats not the point). In development mode, if a user didn''t exist, the while loop would recognize that, and simply return errors. Now it fails to do so. All my other validations on the message seem to work fine, its just this one that fails. The appropriate code: if #other validations on the message else while (i<hold.length) if User.find_by_screen_name(hold[i]) == nil @message.errors.add("Recipient " + hold[i] + " doesn''t exist!") @message.destroy break else if trfa == false @message.recipients = "," + User.find_by_screen_name(hold[i]).get_user_id.to_s + "," trfa = true else @message.recipients = @message.recipients + User.find_by_screen_name(hold[i]).get_user_id.to_s + "," end i+=1 end end @message.sender = find_user_and_messages.get_user_id.to_s @message.save flash[:notice] = "Message Sent!" redirect_to hub_url and return end And as a secondary question, what is it that makes Rails behave differently in production mode? And how do I go about avoiding surprise behavior changes in future apps? Thanks for your help in advance :) -- 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 -~----------~----~----~----~------~----~------~--~---
Dan __
2008-Jun-13 19:59 UTC
Re: TypeError (can''t modify frozen hash) - Production Mode Only
Well, probably a poor fix, but I threw a boolean variable into every validation, and it only runs the lines that were giving a problem if the boolean hasn''t been changed, seems to fix the problem. I''m still curious as to why there are differences between development and production mode though. -- 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 -~----------~----~----~----~------~----~------~--~---
Apparently Analagous Threads
- Read error: #<TypeError: can't modify frozen string> raised from HttpParser
- TypeError: $_ value need to be String (nil given)
- can't modify frozen hash
- TypeError (can't convert Bignum into Hash):
- TypeError: no implicit conversion of Symbol into Hash when submitting form to upload files