1

new to Ruby, decided to start with Padrino framework

was following http://padrinorb.com/guides/getting-started/blog-tutorial/

I created my project using padrino g project blog-tutorial -e erb -c scss -s jquery -d sequel -a mysql2 -b, then I tried to make a model padrino g model post title:string body:text created_at:datetime

but instead I get an error:

/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>'

can't find a solution for this (mysql-devel is installed, mysql2 gem too)

config/database.rb has valid credentials for db connection, e.g. mysql2://root:1@localhost/my_db. Also tried to pass user/password in parameters

  • Are you using Bundler? If so, have you tried another `$ bundle install`, and seeing if the issue persists? – garythegoat Oct 25 '17 at 14:45
  • @garythegoat yes, I use Bundler. As I understand from the docs, flag `-b` is executing `bundle install`. I also did it manually, doesn't change the situation –  Oct 25 '17 at 15:00

2 Answers2

0

The schema plugin was deprecated in Sequel 4.45.0 and removed in Sequel 5.0.0. Switch to using migrations or calling the Sequel::Database schema modification methods directly before creating your model classes.

Jeremy Evans
  • 11,959
  • 27
  • 26
0

The Sequel gem can't find the schema plugin, but the blog tutorial project doesn't seem to need it. Open up the blog-tutorial/config/database.rb file, and comment out the first line:

#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

I tested the whole project like this, except the RSS feed part at the end, and everything worked for me.

DrPepper
  • 237
  • 2
  • 6