Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

1 error prohibited this {{model}} from being saved

Rails is showing the validation messages on the page as such:

1 error prohibited this {{model}} from being saved
There were problems with the following fields:
{{attribute}} {{message}}

Wanting it to show the model names not these these brackets. How do I fix it and why's it doing this?

like image 806
Evolve Avatar asked Dec 13 '22 17:12

Evolve


2 Answers

This is a problem with internationalization in rails. One solution that has worked for some is to downgrade the internationalization gem from 0.5.0 to 0.4.2, like so:

sudo gem uninstall i18n
sudo gem install i18n -v 0.4.2

Of course, if you're using RVM to manage your gems, you don't need sudo in the commands above.

like image 191
Jaime Bellmyer Avatar answered Jan 02 '23 23:01

Jaime Bellmyer


The proper solution involves using bundler to manage your gems instead of using the system defaults and the old Rails 2.x method of embedding it into environment.rb. Bundler segregates your application gems from your system gems properly and removes the problems that occur when using i18n versions 0.4.2 and 0.5 along with Rails 2.x and 3.x.

Steps:

  1. Setup bundler for your Rails 2.3 app
    • http://gembundler.com/rails23.html
  2. In your Gemfile, just completely leave out i18t.
  3. Run 'bundle'

Note: If you do need i18n, just specify the correct version in the Gemfile. Bundler properly segregates your app's gems from your system gems so there will never be the strange behaviors of having both 0.4.2 and 0.5 installed on your system.

like image 26
Onomojo Avatar answered Jan 02 '23 23:01

Onomojo