0

I've been having this problem in the index.rhtml of our app. Basically, I have a dynamic div in the page w/c displays all the information of the currently signed in user's projects.

Here is a snippet where the error occurs:

<% projects.each do |p| %>
  <tr>
    <td><div><%=h p.location %></div></td> <- ERROR
  ...

Note that p.location just returns a string.

The weird thing is, this error does not pop up in my local copy of the app but only occurs in the production server. My local copy is using the same environment as the production server's (gems, Ruby version, Rails version).

Here is my Gem List

*** LOCAL GEMS ***
actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (2.3.5)
bcrypt-ruby (2.1.2)
bson (0.20.1)
bundler (1.0.22)
composite_primary_keys (2.3.5.1)
factory_girl (2.5.1)
fastthread (1.0.7)
ferret (0.11.6)
jnunemaker-validatable (1.8.3)
mocha (0.9.8)
mongo (0.19.3)
mongo_mapper (0.7.3)
mysql (2.8.1)
rack (1.0.1)
rails (2.3.5)
rake (0.9.2.2)
redgreen (1.2.2)
rubygems-bundler (0.2.8)
rvm (1.9.2)
thoughtbot-shoulda (2.11.1)
Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
Normz
  • 271
  • 1
  • 2
  • 9

1 Answers1

0

Found a hacky way of fixing it using iconv. Basically I forced it to utf-8 encoding.

In the model:

class Project < ActiveRecord::Base  
...

  def location
    ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', self[:location] + ' ')[0..-2]
  end

...
end

But this still didn't answer my question how come I can't replicate the error in my local and it only happens in the production server.

Normz
  • 271
  • 1
  • 2
  • 9