Solved

Rails uninitialized constant Iconv

Posted on 2009-05-03
5
2,119 Views
Last Modified: 2013-11-13
Hi there,

I'm having an issue with a RoR website : when trying to save a text change into the database i get the error below

Strange thing is that i imported the database from production where it is working well, under mysql on both development and production...

After being gone through some reasearch, i found this is most likely because of an encoding mismatch. But the encoding in the database.yml is the same in production and dev as well...

Any ideas ?
NameError in Admin/artistsController#update
 

uninitialized constant Iconv
 

RAILS_ROOT: script/../config/..

Application Trace | Framework Trace | Full Trace
 

vendor/rails/activesupport/lib/active_support/dependencies.rb:123:in `const_missing'

vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:78:in `urlnameify'

vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:85:in `attr_to_urlname'

vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:124:in `validate_urlname_against_class'

vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:117:in `validate_urlname'

vendor/rails/activerecord/lib/active_record/validations.rb:790:in `send'

vendor/rails/activerecord/lib/active_record/validations.rb:790:in `run_validations'

vendor/rails/activerecord/lib/active_record/validations.rb:788:in `each'

vendor/rails/activerecord/lib/active_record/validations.rb:788:in `run_validations'

vendor/rails/activerecord/lib/active_record/validations.rb:752:in `valid_without_callbacks'

vendor/rails/activerecord/lib/active_record/callbacks.rb:306:in `valid?'

vendor/rails/activerecord/lib/active_record/validations.rb:723:in `save_without_transactions'

vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'

vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'

vendor/rails/activerecord/lib/active_record/transactions.rb:91:in `transaction'

vendor/rails/activerecord/lib/active_record/transactions.rb:118:in `transaction'

vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'

vendor/rails/activerecord/lib/active_record/base.rb:1439:in `update_attributes'

#{RAILS_ROOT}/app/controllers/admin/artists_controller.rb:45:in `update'
 

vendor/rails/activesupport/lib/active_support/dependencies.rb:123:in `const_missing'

vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:78:in `urlnameify'

vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:85:in `attr_to_urlname'

vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:124:in `validate_urlname_against_class'

vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:117:in `validate_urlname'

vendor/rails/activerecord/lib/active_record/validations.rb:790:in `send'

vendor/rails/activerecord/lib/active_record/validations.rb:790:in `run_validations'

vendor/rails/activerecord/lib/active_record/validations.rb:788:in `each'

vendor/rails/activerecord/lib/active_record/validations.rb:788:in `run_validations'

vendor/rails/activerecord/lib/active_record/validations.rb:752:in `valid_without_callbacks'

vendor/rails/activerecord/lib/active_record/callbacks.rb:306:in `valid?'

vendor/rails/activerecord/lib/active_record/validations.rb:723:in `save_without_transactions'

vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'

vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'

vendor/rails/activerecord/lib/active_record/transactions.rb:91:in `transaction'

vendor/rails/activerecord/lib/active_record/transactions.rb:118:in `transaction'

vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'

vendor/rails/activerecord/lib/active_record/base.rb:1439:in `update_attributes'

vendor/rails/actionpack/lib/action_controller/base.rb:910:in `send'

vendor/rails/actionpack/lib/action_controller/base.rb:910:in `perform_action_without_filters'

vendor/rails/actionpack/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'

vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'

/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'

vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'

vendor/rails/actionpack/lib/action_controller/rescue.rb:82:in `perform_action'

vendor/rails/actionpack/lib/action_controller/base.rb:381:in `send'

vendor/rails/actionpack/lib/action_controller/base.rb:381:in `process_without_filters'

vendor/rails/actionpack/lib/action_controller/filters.rb:377:in `process_without_session_management_support'

vendor/rails/actionpack/lib/action_controller/session_management.rb:117:in `process'

vendor/rails/railties/lib/dispatcher.rb:38:in `dispatch'

vendor/rails/railties/lib/webrick_server.rb:115:in `handle_dispatch'

vendor/rails/railties/lib/webrick_server.rb:81:in `service'

/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'

/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'

/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'

/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'

/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'

/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'

/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'

/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'

/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'

/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'

vendor/rails/railties/lib/webrick_server.rb:67:in `dispatch'

vendor/rails/railties/lib/commands/servers/webrick.rb:59

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'

vendor/rails/activesupport/lib/active_support/dependencies.rb:147:in `require'

vendor/rails/railties/lib/commands/server.rb:30

script/server:3:in `require'

script/server:3
 

vendor/rails/activesupport/lib/active_support/dependencies.rb:123:in `const_missing'

vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:78:in `urlnameify'

vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:85:in `attr_to_urlname'

vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:124:in `validate_urlname_against_class'

vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb:117:in `validate_urlname'

vendor/rails/activerecord/lib/active_record/validations.rb:790:in `send'

vendor/rails/activerecord/lib/active_record/validations.rb:790:in `run_validations'

vendor/rails/activerecord/lib/active_record/validations.rb:788:in `each'

vendor/rails/activerecord/lib/active_record/validations.rb:788:in `run_validations'

vendor/rails/activerecord/lib/active_record/validations.rb:752:in `valid_without_callbacks'

vendor/rails/activerecord/lib/active_record/callbacks.rb:306:in `valid?'

vendor/rails/activerecord/lib/active_record/validations.rb:723:in `save_without_transactions'

vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'

vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:51:in `transaction'

vendor/rails/activerecord/lib/active_record/transactions.rb:91:in `transaction'

vendor/rails/activerecord/lib/active_record/transactions.rb:118:in `transaction'

vendor/rails/activerecord/lib/active_record/transactions.rb:126:in `save'

vendor/rails/activerecord/lib/active_record/base.rb:1439:in `update_attributes'

#{RAILS_ROOT}/app/controllers/admin/artists_controller.rb:45:in `update'

vendor/rails/actionpack/lib/action_controller/base.rb:910:in `send'

vendor/rails/actionpack/lib/action_controller/base.rb:910:in `perform_action_without_filters'

vendor/rails/actionpack/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'

vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'

/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'

vendor/rails/actionpack/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'

vendor/rails/actionpack/lib/action_controller/rescue.rb:82:in `perform_action'

vendor/rails/actionpack/lib/action_controller/base.rb:381:in `send'

vendor/rails/actionpack/lib/action_controller/base.rb:381:in `process_without_filters'

vendor/rails/actionpack/lib/action_controller/filters.rb:377:in `process_without_session_management_support'

vendor/rails/actionpack/lib/action_controller/session_management.rb:117:in `process'

vendor/rails/railties/lib/dispatcher.rb:38:in `dispatch'

vendor/rails/railties/lib/webrick_server.rb:115:in `handle_dispatch'

vendor/rails/railties/lib/webrick_server.rb:81:in `service'

/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'

/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'

/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'

/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'

/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'

/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'

/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'

/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'

/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'

/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'

vendor/rails/railties/lib/webrick_server.rb:67:in `dispatch'

vendor/rails/railties/lib/commands/servers/webrick.rb:59

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'

vendor/rails/activesupport/lib/active_support/dependencies.rb:147:in `require'

vendor/rails/railties/lib/commands/server.rb:30

script/server:3:in `require'

script/server:3
 

This error occured while loading the following files:

   active_record/acts/urlnameable/instance_methods/iconv.rb
 

Request
 

Parameters: {"artist"=>{"name"=>"Alexandra Maria Lara", "name_ja"=>"Alexandra Maria Lara", "name_fr"=>"Alexandra Maria Lara", "splash_image_temp"=>"", "bio_ja"=>"", "bio_fr"=>"V&eacute;ritable star en Allemagne, son pays d'adoption, cette jeune actrice d'origine roumaine a &eacute;t&eacute; rep&eacute;r&eacute;e dans <em>La Chute</em>, de Olivier Hirschbiegel ou encore dans <em>Control</em>, de Anton Corbijn.<br /> Apr&egrave;s un r&ocirc;le dans <em>L'homme sans &acirc;ge</em>, de Francis Ford Coppola, on la verra dans <em>The City of Your Final Destination</em>, de James Ivory. Elle vient &eacute;galement de tourner avec Spike Lee et Stephen Daldry (<em>Billy Elliot</em>).", "name_zh"=>"", "bio_zh"=>"", "splash_image"=>#<StringIO:0x1b6e4e0>, "bio"=>"", "artist_cat"=>"0"}, "commit"=>"Enregistrer", "id"=>"38"}
 

Show session dump
 

--- 

:authenticated: true

flash: !map:ActionController::Flash::FlashHash {}
 
 

Response

Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}

Open in new window

0
Comment
Question by:terencepires
  • 3
  • 2
5 Comments
 
LVL 24

Expert Comment

by:fridom
Comment Utility
Obviously on your development machine the Iconv library is not installed.

On Debian you can change that with apt-get install libiconv-ruby
or apt-get install ruby1.8-dev. That seems to be the most reasonable approach
for getting a bit more running on your System.

You may try your luck with a Gem install on other systems or check the
site of your distribution on how to get libiconv for Ruby

Regards
Friedrich

0
 
LVL 1

Author Comment

by:terencepires
Comment Utility
Hi friedrich,

first off, thanks for your help !

i tried to reinstall iconv following your lead but it had no effect on my error....
I then found a tutorial here, which i tried too (it's in french) :
 
http://t37.net/ruby-iconv-et-freebsd-sont-dans-un-bateau.html

sadly, it had no effect as well...

And when browsing the internet i can't seem to find anything addressing my issue...
0
 
LVL 1

Author Comment

by:terencepires
Comment Utility
one more thing,
iconv.bundle was already installed in my version of Ruby.
0
 
LVL 24

Accepted Solution

by:
fridom earned 500 total points
Comment Utility
The mentioned URL assumes that the development  files for iconv are installed. That seems to be not the case on your system. So check where you can get the headers and libraries for compiling iconv. So in fact my comment above still hold the development files for Iconv are not there. I can't tell where to get prebuld libraries for Mac, but mac is an Unix and so compiling iconf should be very doable...

Regards
Friedrich
0
 
LVL 1

Author Closing Comment

by:terencepires
Comment Utility
thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now