Search code examples
ruby-on-railshelperactivemodeluninitialized-constant

Error while typing rails server command


I am a beginner.I am trying to launch rails server using the command.But I am getting an error. I tried searching in the google but no results.I will attach a picture of the log I got when I executed that command.enter image description here


Solution

  • What Mysql error are you getting?

    And what is in your config/database.yml?

    So far, you have created the folder structure for a Rails app (rails new), then installed all the relevant components (bundle install).

    When you start the server (rails server) it starts in "development" mode (you also have "test" mode for unit tests and "production" mode for when your app is live - and each has slightly different options). One of the first things the Rails server tries to do is connect to the database, so it looks in config/database.yml for the database specified in the development section.

    So probably, it's trying to connect to a database that doesn't exist yet, with a username and password that are wrong.

    First thing to do is to update the username and password in config/database.yml to match your local Mysql server.

    Second thing to do is to build the development database; the command for that is "bin/rake db:create" (or "bundle exec rake db:create" if you're on Rails 3.x).

    Hopefully that should be enough to get your server started.