2일째 예제에 질문이 있습니다.

13 views
Skip to first unread message

SGcom

unread,
May 15, 2008, 9:47:05 AM5/15/08
to jruby-on-rails-for-web-and-enterprise
jruby 1.1에 rails2.0.2를 설치해서 개발툴로는 Netbean를 쓰고 있습니다.
책에 쓰여져 있는데로 코드를 입력해서 돌려 봤습니다.
원하는 것은 나오지 않고 에러가 뜨네요. ㅡㅡ;

Errno::ENOENT in WelcomeController#who

No such file or directory - /tmp/mysql.sock

RAILS_ROOT: /home/jngit/NetBeansProjects/hello
Application Trace | Framework Trace | Full Trace

/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/vendor/mysql.rb:107:in `real_connect'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/connection_adapters/mysql_adapter.rb:471:in `connect'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/connection_adapters/mysql_adapter.rb:165:in `initialize'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/connection_adapters/mysql_adapter.rb:88:in `new'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/connection_adapters/mysql_adapter.rb:88:in
`mysql_connection'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
291:in `connection='
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
259:in `retrieve_connection'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
78:in `connection'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/query_cache.rb:8:in `cache'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/caching.rb:677:in `perform_action_with_caching'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/base.rb:524:in `process'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/filters.rb:685:in `process_with_filters'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/session_management.rb:123:in
`process_with_session_management_support'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/base.rb:388:in `process'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/dispatcher.rb:171:in `handle_request'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/dispatcher.rb:115:in `dispatch'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/dispatcher.rb:126:in `dispatch_cgi'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/dispatcher.rb:9:in `dispatch'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/
webrick_server.rb:112:in `handle_dispatch'
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/
webrick_server.rb:78:in `service'
/usr/lib/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/jruby-1.1/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/jruby-1.1/lib/ruby/1.8/webrick/server.rb:173:in
`start_thread'
:1:in `start'

참고로 우분투 8.0.4 환경 입니다.

SGcom

unread,
May 15, 2008, 10:11:12 AM5/15/08
to jruby-on-rails-for-web-and-enterprise
추가로 만든 것이 http://127.0.0.1:3000/welcome/who로 테스트를 했구요
레일스 2.0은 뷰가 *.html.erb로 만들어 지더군요. *.rhtml과 어떤 차이가 있는 것인가요??

완전 초짜로서 필자에게 감히 질문드립니다.
그리고 제가 앞서 글에서 그냥 문제점만 남겨놔서 죄송합니다.

바쁘시더라도 한 수 가르쳐 주시면 아니되겠습니까?

Changshin Lee

unread,
May 16, 2008, 10:05:31 PM5/16/08
to jruby-on-rails-for...@googlegroups.com

2008. 05. 15, 오후 11:11, SGcom 작성:

> 추가로 만든 것이 http://127.0.0.1:3000/welcome/who로 테스트를 했구요
> 레일스 2.0은 뷰가 *.html.erb로 만들어
> 지더군요. *.rhtml과 어떤 차이가 있는 것인가요??

근본적인 차이는 없습니다만, 레일즈 2.0부
터 좀 더 범용적인 템플릿 지원의 차원에서 포멧.erb를 쓰게 되었습니다.
앞서 질문도 곧 답변해드리겠습니다.
고맙습니다.

SGcom

unread,
May 18, 2008, 8:15:17 PM5/18/08
to jruby-on-rails-for-web-and-enterprise
감사합니다. ^^ 다른답변도 기다리고 있을께요,,,

Changshin Lee

unread,
May 19, 2008, 3:40:19 AM5/19/08
to jruby-on-rails-for...@googlegroups.com
안녕하세요?
아래 문제는 MySQL 설치시 기본 소켓 설정
이 아닌 다른 경로에 소켓을 써서 발생한 것입니다.
즉 기본 설정은 /tmp/mysql.sock 인데,
MySQL 설치본에 따라 예를 들어 /var/
mysql.sock과 같이 기본 설정과 다른 경우가 있습니
다. 이 때에는 config/database.yml에

development:
encoding: utf8
adapter: mysql
database: hello_development
username: root
password: ror
host: localhost
socket: /opt/local/var/run/mysql5/mysqld.sock

와 같이 socket 항목에 자신의 설정을 넣어주면 됩니다.
고맙습니다.

2008. 05. 15, 오후 10:47, SGcom 작성:

SGcom

unread,
May 23, 2008, 4:27:47 AM5/23/08
to jruby-on-rails-for-web-and-enterprise
친절하게 답변해 주셔서 감사합니다.
그런데 창신 님 께서 말씀하신데로 제위치를 지정해도
/usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/
initializer.rb:233:in `database_configuration': ParserException while
scanning a block mapping we had this expected <block end>, but found
org.jvyamlb.tokens.ScalarToken (ArgumentError)
from /usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/
initializer.rb:233:in `initialize_database'
from /usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/
initializer.rb:94:in `process'
from /usr/lib/jruby-1.1/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/
initializer.rb:49:in `run'
from /home/jngit/studyPrj/Hello/config/environment.rb:20
에러가 뜨더군요.

ParseError라고 하길래 database.yaml을 그대로 복사해서 보여드리겠습니다.
development:
adapter:mysql
encoding:utf8
database:Hello_development
username:root
password:jngit1234
# JRuby doesn't support socket:
host:localhost
socket:/var/run/mysqld/mysqld.sock

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
adapter: mysql
encoding: utf8
database: Hello_test
username: root
password:jngit1234
socket: /var/run/mysqld/mysqld.sock

production:
adapter: mysql
encoding: utf8
database: Hello_production
username: root
password: jngit1234
socket: /var/run/mysqld/mysqld.sock

사실 JRuby가 소켓을 지원 안한다는 주석이 달려 있어 주석을 지우고 해봐도 여전히 같은 에러가 나네요..
설마 DB를 만들어 주지 않았다고 이런 에러가 뜨지는 않겠죠??
감사합니다. ^^;;

Changshin Lee

unread,
May 23, 2008, 4:33:20 AM5/23/08
to jruby-on-rails-for...@googlegroups.com
NetBeans로 DB를 먼저 만드신 다음 시도해보세요.
JDBC를 쓰므로 사실 socket 설정은 필요 없을 수도 있습니다.

2008. 05. 23, 오후 5:27, SGcom 작성:

SGcom

unread,
May 27, 2008, 8:26:38 AM5/27/08
to jruby-on-rails-for-web-and-enterprise
Netbeans로 DB를 전부 다 만들어 봤지만 똑같네요..ㅜㅜ

Changshin Lee

unread,
May 27, 2008, 9:33:49 AM5/27/08
to jruby-on-rails-for...@googlegroups.com
제가 NetBeans 6.1로 테스트삼아 만든 레일즈 프로젝트를 첨부합니다.
config/database.yml
을 참고해보세요.
저는 
test_rails_development 
DB를 만든 다음 이 프로젝트를 실행하고
를 브라우저로 열면 잘 됩니다.
참고로 제가 설치한 젬은
  • actionmailer (2.0.2) : Service layer for easy email delivery and testing.
  • actionpack (2.0.2) : Web-flow and rendering framework putting the VC in MVC.
  • activerecord (2.0.2) : Implements the ActiveRecord pattern for ORM.
  • activerecord-jdbc-adapter (0.8) : JDBC adapter for ActiveRecord, for use within JRuby on Rails.
  • activeresource (2.0.2) : Think Active Record for web resources.
  • activesupport (2.0.2) : Support and utility classes used by the Rails framework.
  • rails (2.0.2) : Web-application framework with template engine, control-flow layer, and ORM.
  • rake (0.8.1) : Ruby based make-like utility.
  • rspec (1.1.3) : RSpec-1.1.3 (build 20080131122909) - BDD for Ruby http://rspec.rubyforge.org/
  • ruby-debug-base (0.10.0) : Java implementation of Fast Ruby Debugger
  • ruby-debug-ide (0.1.10) : IDE interface for ruby-debug.
  • sources (0.0.1) : This package provides download sources for remote gem installation
입니다.
Tools > Ruby Gems > Installed 에서 확인할 수 있습니다.

2008. 05. 27, 오후 9:26, SGcom 작성:
test_rails.zip

Changshin Lee

unread,
Jun 10, 2008, 10:26:46 AM6/10/08
to jruby-on-rails-for...@googlegroups.com
해결 되셨는지요?
혹시 아직 해결이 안되셨다면,
http://www.onoffmix.com/e/ikspres/157
에 소개된 세미나에 제가 발표를 하는데,
그날 사용하시는 환경의 노트북을 가져오셔서 함께 풀어보면 좋겠습니다.
성공하세요.

2008. 05. 27, 오후 9:26, SGcom 작성:

> Netbeans로 DB를 전부 다 만들어 봤지만 똑같네요..ㅜㅜ
> >

SGcom

unread,
Aug 6, 2008, 2:18:03 AM8/6/08
to jruby-on-rails-for-web-and-enterprise
개발자의 게으름이 모두 그렇듯
사실 그 이후로 루비책조차도 피지 못했습니다. ㅠㅠ
잘 가르쳐 주셨는데 죄송해요.

너무 마음의 여유가 없어 세미나도 가보지 못했네요.
다시 책을 펴고 공부해보겠습니다.
Reply all
Reply to author
Forward
0 new messages