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 ![]()