Ruby新手,决定从Padrino框架开始
正在关注http://padrinorb.com/guides/getting-started/blog-tutorial/
我使用padrino g project blog-tutorial -e erb -c scss -s jquery -d sequel -a mysql2 -b
创建了我的项目,然后我尝试制作模型padrino g model post title:string body:text created_at:datetime
但我得到一个错误:
/home/user/.rvm/gems/ruby-2.4.1/gems/sequel-5.1.0/lib/sequel/model/base.rb:914:in `require': cannot load such file -- sequel/plugins/schema (LoadError)
from /home/user/.rvm/gems/ruby-2.4.1/gems/sequel-5.1.0/lib/sequel/model/base.rb:914:in `plugin_module'
from /home/user/.rvm/gems/ruby-2.4.1/gems/sequel-5.1.0/lib/sequel/model/base.rb:533:in `plugin'
from /home/user/Sites/blog-tutorial/config/database.rb:1:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.4.1/gems/padrino-core-0.14.1.1/lib/padrino-core/reloader.rb:91:in `require'
from /home/user/.rvm/gems/ruby-2.4.1/gems/padrino-core-0.14.1.1/lib/padrino-core/reloader.rb:91:in `safe_load'
from /home/user/.rvm/gems/ruby-2.4.1/gems/padrino-core-0.14.1.1/lib/padrino-core/loader.rb:154:in `block in require_dependencies'
from /home/user/.rvm/gems/ruby-2.4.1/gems/padrino-core-0.14.1.1/lib/padrino-core/loader.rb:152:in `each'
from /home/user/.rvm/gems/ruby-2.4.1/gems/padrino-core-0.14.1.1/lib/padrino-core/loader.rb:152:in `require_dependencies'
from /home/user/.rvm/gems/ruby-2.4.1/gems/padrino-core-0.14.1.1/lib/padrino-core/loader.rb:57:in `load!'
from /home/user/Sites/blog-tutorial/config/boot.rb:60:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.4.1/gems/padrino-gen-0.14.1.1/lib/padrino-gen/generators/cli.rb:26:in `require'
from /home/user/.rvm/gems/ruby-2.4.1/gems/padrino-gen-0.14.1.1/lib/padrino-gen/generators/cli.rb:26:in `load_boot'
from /home/user/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
from /home/user/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from /home/user/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `block in invoke_all'
from /home/user/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `each'
from /home/user/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `map'
from /home/user/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `invoke_all'
from /home/user/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/group.rb:232:in `dispatch'
from /home/user/.rvm/gems/ruby-2.4.1/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
from /home/user/.rvm/gems/ruby-2.4.1/gems/padrino-gen-0.14.1.1/bin/padrino-gen:16:in `<main>'
无法找到解决方案(mysql-devel
已安装,mysql2
gem也是如此)
config/database.rb
具有数据库连接的有效凭据,例如mysql2://root:1@localhost/my_db
。还尝试在参数
答案 0 :(得分:0)
架构插件在续集4.45.0中已弃用,已在续集5.0.0中删除。在创建模型类之前,切换到使用迁移或直接调用Sequel :: Database模式修改方法。
答案 1 :(得分:0)
Sequel gem无法找到架构插件,但博客教程项目似乎并不需要它。打开blog-tutorial / config / database.rb文件,注释掉第一行:
#Sequel::Model.plugin(:schema)
Sequel::Model.raise_on_save_failure = false # Do not throw exceptions on failure
Sequel::Model.db = case Padrino.env
when :development then Sequel.connect("sqlite://db/blog_tutorial_development.db", :loggers => [logger])
when :production then Sequel.connect("sqlite://db/blog_tutorial_production.db", :loggers => [logger])
when :test then Sequel.connect("sqlite://db/blog_tutorial_test.db", :loggers => [logger])
end
我测试了整个项目,除了最后的RSS提要部分,一切都适合我。