Rails vs FreeBSD

ruby on rails, Программизм

Tagged Under :

И был это зимний вечер, и шел почему-то долждь а не снег, и видать по этому случилось такое:

rails test
/usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/bin/../lib/rails_generator/options.rb:32:in `default_options’: undefined method `write_inheritable_attribute’ for Rails::Generator::Base:Class (NoMethodError)
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/bin/../lib/rails_generator/base.rb:90
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/bin/../lib/rails_generator.rb:34
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/bin/rails:13
from /usr/local/bin/rails:19:in `load’
from /usr/local/bin/rails:19
Читать дальше »

Миграция – типы данных

ruby on rails

Tagged Under : ,

db2 mysql openbase oracle:

:binary blob(32768)  blob         object     blob

:boolean decimal(1)   tinyint(1)   boolean    number(1)

:date date         date         date       date

:datetime timestamp    datetime     datetime   date

:decimal decimal      decimal      decimal    decimal

:float float         float         float       number

:integer int          int(11)      integer    number(38)

:string varchar(255) varchar(255) char(4096) varchar2(255)

:text clob(32768)  text         text       clob

:time time         time         time       date

:timestamp timestamp    datetime     timestamp  date

ultrasphinx, заметки

ruby on rails, Программизм

Tagged Under :

1. Обращаем внимание на то, что говорит нам сервер при запуске. Если имеется

** ultrasphinx: configuration file not found for “development” environment
** ultrasphinx: please run ‘rake ultrasphinx:configure’
** ultrasphinx: spelling support not available (raspell configuration raised “uninitialized constant Ultrasphinx::Spell::Aspell”)

то соответственно делаем rake ultrasphinx:configure

у меня результат был такой:

Rebuilding configurations for development environment
Available models are User, Keyword, and Classification
Generating SQL

Рестартим сервер, и скорее всего видим:

** ultrasphinx: spelling support not available (raspell configuration raised “uninitialized constant Ultrasphinx::Spell::Aspell”)
** ultrasphinx: spelling support not available (raspell configuration raised “uninitialized constant Ultrasphinx::Spell::Aspell”)

гугль показал такое

цитата:

You just need to install the aspell, spell checking library and raspell, the Ruby interface to aspell. The raspell README has instructions for installing aspell and raspell on both Mac and Ubuntu.

Я пошел по такому пути -
aspell – скачал архив с вышесказанного сайта и установил
raspell – установил через гемы (gem install raspell)

После этих действий при старте сервера уже видим

** ultrasphinx: spelling support not available (raspell configuration raised “No word lists can be found for the language “ap”.”)

Идем сюда и читаем главу про Setup (examples/ap.multi находится в нашем rails проекте)

Запускаем сервер и любуемся:
** ultrasphinx: spelling support enabled

2. Неплохо было бы запустить демон ультрасфинкса
rake ultrasphinx:daemon:start

у меня он не запустился. Идем еще раз читать доки раздел Installation и выясняем, что нужен, как минимум Sphinx. Ставим (я брал отсюда). Обновляем индекс

rake ultrasphinx:index

$ indexer –config ‘/home/vint/artculture/config/ultrasphinx/development.conf’ –all
Sphinx 0.9.8.1-release (r1533)
Copyright (c) 2001-2008, Andrew Aksyonoff

using config file ‘/home/vint/artculture/config/ultrasphinx/development.conf’…
indexing index ‘main’…
WARNING: DOCID_MAX document_id, skipping
collected 2336 docs, 3.4 MB
sorted 0.5 Mhits, 100.0% done
total 2336 docs, 3390756 bytes
total 119.252 sec, 28433.57 bytes/sec, 19.59 docs/sec

Пытаемся опять запустить демона
rake ultrasphinx:daemon:start

Sphinx 0.9.8.1-release (r1533)
Copyright (c) 2001-2008, Andrew Aksyonoff

using config file ‘/home/vint/artculture/config/ultrasphinx/development.conf’…
creating server socket on 0.0.0.0:3312
Started successfully

отношения Activ Record

ruby on rails, Программизм

Имена класса и таблицы - имя таблицы БД происходит от имени класса Active Record (во мнежественном числе, т.е. если имя класса User то таблица будет users).

Внешние ключи – должны иметь имя <class>_id

belongs_to – отношение “много к одному”

has_many – один ко многим

has_one – один к одному

has_and_belongs_to_many

ruby, hash

ruby on rails, Программизм

  1. users_hash = {“tom” => “password0″,
  2. “adi” => “password1″,
  3. “aaron” => “password2″ }
  4. # The following line will not add anything to users_hash.
  5. # But will return a hash that has users_hash and
  6. # the new added entry.
  7. users_hash.merge({“sam1″ => “password3″})
  8. #The following line will modify users_hash by
  9. #adding the new entry and return it
  10. users_hash.merge!({“sam2″ => “password3″})
  11. # or you can make it like this
  12. #users_hash.merge!(“sam2″ => ”password3″)
  13. users_hash.each { |key, value|
  14. puts “Key is #{key} and value is #{value}”
  15. }

Проблемы с установкой gem`а mysql

ruby on rails

Tagged Under : ,

Никак не получалось установить гем mysql ля. Выскакивала ошибка

Building native extensions. This could take a while…
ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

Полный лог был таков -

gem install mysql
Select which gem to install for your platform (x86_64-linux)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. Skip this gem
6. Cancel installation
> 4
Building native extensions. This could take a while…
ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… yes
checking for mysql_query() in -lmysqlclient… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/bin/ruby
–with-mysql-config
–without-mysql-config
–with-mysql-dir
–without-mysql-dir
–with-mysql-include
–without-mysql-include=${mysql-dir}/include
–with-mysql-lib
–without-mysql-lib=${mysql-dir}/lib
–with-mysqlclientlib
–without-mysqlclientlib
–with-mlib
–without-mlib
–with-mysqlclientlib
–without-mysqlclientlib
–with-zlib
–without-zlib
–with-mysqlclientlib
–without-mysqlclientlib
–with-socketlib
–without-socketlib
–with-mysqlclientlib
–without-mysqlclientlib
–with-nsllib
–without-nsllib
–with-mysqlclientlib
–without-mysqlclientlib

Gem files will remain installed in /usr/lib64/ruby/gems/1.8/gems/mysql-2.6 for inspection.
Results logged to /usr/lib64/ruby/gems/1.8/gems/mysql-2.6/gem_make.out

Читать дальше »

Реклама: