【问题标题】:Getting the RailsKits SaaS app up and running w/ a mysql2 server使用 mysql2 服务器启动并运行 RailsKits SaaS 应用程序
【发布时间】:2012-11-24 02:28:36
【问题描述】:

我对 Rails 游戏还很陌生;我是一名前端开发人员,自学编程。我已经构建了一个 Web 应用程序,并决定使用RailsKit SaaS 工具包来处理我的注册等。我在启动和运行默认应用程序时遇到了问题,但我确定这是由于我缺乏知识,我认为这与设置 mysql 服务器有关(通常我使用 sqlite3,但这并不似乎也无法使用此应用程序)。

这是我遇到的过程和错误,我仍然无法创建数据库或启动服务器...

  1. 已下载应用

  2. Ran bundle install.得到以下错误:

    Gem::InstallError: factory_girl requires Ruby version >= 1.9.2. 
    An error occurred while installing factory_girl (4.1.0), and Bundler cannot continue.
    Make sure that `gem install factory_girl -v '4.1.0'` succeeds before bundling.
    
  3. 发现我运行的是 Ruby 版本 1.8.7,所以我将其添加到 Gemfile:

    gem 'rake','1.9.2' and **updated my system** to 1.9.2
    
  4. bundle install得到以下错误:

    An error occurred while installing mysql2 (0.3.11), and Bundler cannot continue.
    Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.
    
  5. 于是我跑了gem install mysql2 -v '0.3.11,得到以下错误:

    ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.
    
    /Users/trevanhetzel/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb
    checking for rb_thread_blocking_region()... yes
    checking for rb_wait_for_single_fd()... yes
    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... no
    checking for mysql_query() in -lmysqlclient... no
    checking for main() in -lmygcc... no
    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.
    

这就是我所在的地方。如果这有帮助,经过上述所有步骤,我尝试通过rake db:create 创建一个数据库并得到了

Could not find gem 'mysql2 (>= 0) ruby' in the gems available on this machine.

所以我猜我的机器上没有安装 MySQL?似乎有点奇怪,因为我一直使用 MAMP 和 MySQL 服务器。

任何能帮助我指明正确方向的人都是好人!我真的很感激。

【问题讨论】:

  • 您使用的是哪个操作系统?对于 OSX,请参阅此答案:stackoverflow.com/questions/4115126/…
  • OSX。我已经过去了,现在可以启动服务器了。迁移时出现此错误:'Trevan-Hetzels-MacBook-Pro:V4 trevanhetzel$ rake db:create db:migrate saas:bootstrap rake aborted!未定义方法trial_interval' for # <SubscriptionPlan:0x007fd3243af9b8> /Users/trevanhetzel/.rvm/gems/ruby-1.9.3-p327/gems/activemodel-3.2.8/lib/active_model/attribute_methods.rb:407:in method_missing' /Users/trevanhetzel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.8/lib/active_record/attribute_methods.rb:149:in'...跨度>
  • 此问题是由于随套件提供的迁移中缺少字段。这已得到修复。 :)
  • @BenjaminCurtis 哦,好吧。迁移时仍然出现错误:Trevan-Hetzels-MacBook-Pro:V4 trevanhetzel$ rake db:migrate rake aborted! undefined local variable or method `config' for main:Object /Sidecar/V4/config/application.rb:3 /Sidecar/V4/Rakefile:4 (See full trace by running task with --trace) 并且无法启动服务器。我还需要做什么吗?
  • @BenjaminCurtis 没关系,这是因为我将config.assets.paths += ["app/assets/public"] 添加到application.rb。我现在可以启动服务器,但仍然遇到上述关于未定义的 'trial_interval' 方法的错误。

标签: ruby-on-rails development-environment mysql2


【解决方案1】:

bundle exec rake db:migrate 听起来像。

【讨论】:

  • 'bundle exec rake db:migrate' 现在给了我这个:/Library/Ruby/Gems/1.8/gems/saas-kit-2.5.4/lib/saas/extensions/active_merchant/billing/ gateways/paypal.rb:31:警告:已经初始化常量 RECURRING_ACTIONS /Library/Ruby/Gems/1.8/gems/saas-kit-2.5.4/lib/saas/extensions/active_merchant/billing/gateways/paypal_express_recurring.rb:12 :警告:已初始化常量 LIVE_REDIRECT_URL /Library/Ruby/Gems/1.8/gems/saas-kit-2.5.4/lib/saas/extensions/active_merchant/billing/gateways/paypal_express_recurring.rb:13:警告:已初始化常量 TEST_REDIRECT_URL
  • 您可以使用bundle exec rails c 访问控制台吗...您不应该看到错误,而是像闪烁的光标,可能是 1> 或类似的东西。另外,mysql -u root 看看你的机器上是否有 mysql。你选择了一个不错的主题来作为你的第一次尝试:-)
  • 是的,我可以访问控制台。 mysql -u root 给了我一个找不到的命令,所以它显然不在我的机器上。我想我会坚持使用 sqlite3,因为它正在工作(除了上面的错误)。我知道,对吧?我倾向于通过将自己一头扎进疯狂的废话中并试图从中游出来来学习:)
【解决方案2】:

在安装 mysql2 gem 之前,您需要在系统中安装 mysql 客户端和服务器。所以试试这个。

  $sudo apt-get update
  $sudo apt-get install mysql-server mysql-client

在此之后尝试安装 gem mysql2

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-15
    • 2014-10-24
    • 1970-01-01
    • 2015-07-22
    • 1970-01-01
    • 2016-06-03
    • 1970-01-01
    相关资源
    最近更新 更多