Tag: migration

Rails 3 + Errors#on have been deprecated, use Errors#[] instead

Probably you have already noticed that, but in Rails 3 got some new stuff going on. Same goes when testing Rails applications. Using errors.in(:key) is now deprecated so you'll probably need to change a whole bunch of tests and assertions. However, there is a quite fast way to do it. Open project in Netbeans and use Replace in project.

Go to Edit --> Replace in projects and type into corresponding fields:

Containing text: errors.on\((.+)\)\,
Replace With: errors\[$1\].first\,

Select "regular expression" and press find. Wait few seconds for the results and press replace.

After that rerun your tests:

rake test:all
# or if rspec
rake spec

Rails 3 + incompatible character encodings: UTF-8 + Mysql + Ruby 1.9

Jeśli dostajemy taki błąd:

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT)

w nowych Railsach, korzystając z Mysqla, oznacza to że pora zmienić driver do bazy ;)

W gemfile'u zamiast:

gem 'mysql'

Należy użyć:

gem 'ruby-mysql'

Po tym zabiegu, musimy jeszcze w pliku database.yml podać ścieżkę do socketu mysqla. Aby wykryć gdzie on się znajduje, musimy wpisać następującą komendę do konsoli:

mysql_config --socket

Otrzymane dane wprowadzamy w taki sposób:

socket: /var/run/mysqld/mysqld.soc

Tyle :)

Copyright © 2024 Closer to Code

Theme by Anders NorenUp ↑