新手问题 在看教程做第一个 blog 出现点问题,求帮助。

surgit · 2013年04月17日 · 最后由 chenge 回复于 2013年04月17日 · 4068 次阅读

rails s -p214 的 把 rails 跑在 214 端口了,然后用 nginx 做了代理,绑定到了域名上 blog.rubyless.com/posts 上面,不过在新建 post 的时候,总是会返回 localhost 的连接上。怎么办呢?

rails s -e production -p 214 指定到产品版环境试下

#1 楼 @Zernel 多谢 ,我试试。

#1 楼 @Zernel rails s -e production -p 214 这里的 production 是固定参数么?还是根据什么来改变的?因为我运行了一下发生了错误。

同志们。。。给个回复。。

粗线了这个问题: /usr/local/ruby/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in `resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified) 因为数据库配的是 development 所以自己把 production 换成 development 也不行。。。

database.yml 里不是可以配置 development 和 production 环境下的数据库,配置一下就行了吧。

#6 楼 @eva databse 里的 production 的已经添加了,出现的错误提示 /usr/local/ruby/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in `resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)

贴出你的 database.yml 看看

developmengt:
  adapter: mysql2
  database: blog
  pool: 5
  username: root
  encoding: utf8
  host: localhost
  password: 

production:
  adapter: mysql2
  database: blog
  poll: 5
  username: root
  encoding: utf8
  host: localhost
  password: 

#8 楼 @zlx_star

RAILS_ENV=production rails s, 试试看。

#10 楼 @chenge 还是一样,不知道是不是哪里的代码写错了还是怎的。

搜索下这个错误 AdapterNotSpecified

poll: 5,应该是 pool 吧。

不过还是一样
ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
  actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
  railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
  activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
  railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.5) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.5) lib/rack/lock.rb:15:in `call'
  rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
  rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
  rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
  rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
  rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
  railties (3.2.13) lib/rails/engine.rb:479:in `call'
  railties (3.2.13) lib/rails/application.rb:223:in `call'
  rack (1.4.5) lib/rack/content_length.rb:14:in `call'
  railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
  rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
  /usr/local/ruby/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
  /usr/local/ruby/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
  /usr/local/ruby/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'


Started POST "/posts" for 221.228.228.14 at 2013-04-17 07:24:05 +0000
Processing by PostsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"tmnOm/msN5fGIqpXUhq3TVoUImGsKNxJy8s8CSWoN9Q=", "post"=>{"title"=>"231388", "content"=>"2132188"}, "commit"=>"Create Post"}
Redirected to http://127.0.0.1:214/posts/7
Completed 302 Found in 15ms (ActiveRecord: 2.1ms)

favicon.ico 放在 public 目录。 基本解决了吧。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册