rails sqlite adapter error

前端 未结 6 1829
傲寒
傲寒 2020-12-16 12:21

I\'m following the instructions in rails tutorial and got stuck when trying to use the scaffold command.

When running:

rails generate scaffold User n         


        
6条回答
  •  囚心锁ツ
    2020-12-16 12:56

    Also on Rails Tutorial, ran:

      $ rake db:migrate
    

    Got the following error:

    Please install the sqlite3 adapter: gem install activerecord-sqlite3-adapter (sqlite3 is not part of the bundle. Add it to Gemfile.).

    Ran:

    $ gem install activerecord-sqlite3-adapter

    Got:

    ERROR: Could not find a valid gem 'activerecord-sqlite3-adapter' (>= 0) in any repository

    Changed Gemfile according to one of the answers above:

    gem 'sqlite3', '1.3.4'

    Got another error so had to install:

    $ gem install sqlite3 -v '1.3.4'
    

    Tried running $ rake db:migrate again, but got another error, this time resembling the answer above:

    Please install the sqlite3 adapter: gem install activerecord-sqlite3-adapter (can't activate sqlite3 (~> 1.3.5), already activated sqlite3-1.3.4. Make sure all dependencies are added to Gemfile.)

    So changed Gemfile to:

    gem 'sqlite3', '1.3.5'

    And got another error message to make sure 'gem install sqlite3 -v '1.3.5' succeeds (wtf?! alright again). Installed it successfully, ran bundle install.

    Tried running:

    $ rake db:migrate
    

    Nothing happened, so tried:

    $ bundle exec rails generate scaffold User name:string email:string
    

    Per another suggestion above. And it finally worked. The tutorial warned of a laborious setup process, but I felt like I had to mix and match from at least 5 other people. Hope this helps the next person.

提交回复
热议问题