You can verify that the page is there by running your server: $ rails serverĪnd visiting in your browser. In file config/routes.rb, on line 2 add: root 'welcome#index' We’ll edit config/routes.rb to set the index page to our new method: Now we need to make Rails route to this action. ![]() In file app/views/welcome/ write: Hello World We will first create a controller called welcome for our home page to live: $ rails generate controller welcome When you’re using a new app, there will not be a root page in production, so we need to create one. Rails 6 no longer has a static index page in production by default. If you omit the sql at the end of postgresql in the adapter section, your application will not work. # for a full overview on how database connection configuration can be specified.īe careful here. # For details on connection pooling, see Rails configuration guide # Install PostgreSQL and put its /bin directory on your path. # gem install pg -with-pg-config=/opt/local/lib/postgresql84/bin/pg_config # gem install pg -with-pg-config=/usr/local/bin/pg_config The development section of your config/database.yml file should look something like this: $ cat config/database.yml In addition to using the pg gem, ensure that your config/database.yml file is using the postgresql adapter. ![]() Now re-install your dependencies (to generate a new Gemfile.lock): $ bundle installįor more information on why Postgres is recommended instead of Sqlite3, see why you cannot use Sqlite3 on Heroku. Install Postgres locally now if it is not already on your system. Maintaining parity between your development and deployment environments prevents subtle bugs from being introduced because of differences between your environments. We highly recommend using PostgreSQL during development. Edit your Gemfile and change this line: gem 'sqlite3' If you’re using an existing app that was created without specifying -database=postgresql, you need to add the pg gem to your Rails project. $ bundle lock -add-platform x86_64-linux -add-platform rubyĬreate a database locally: $ bin/rails db:createĭatabase 'myapp_development' already exists Then move into your application directory. Then create a new app and move into its root directory: $ rails new myapp -database=postgresql If necessary, you can get the new version of rails by running the following: $ gem install rails -v 6.1.7.3 -no-document To create a new app, first make sure that you’re using Rails 6.x by running rails -v. Create a new Rails app (or upgrade an existing one) ![]() Press Enter at the prompt to upload your existing ssh key or create a new one, used for pushing code later on. Uploading ssh public key /Users/adam/.ssh/id_rsa.pub ![]() Log in using your Heroku account’s email address and password: $ heroku login Once installed, the heroku command is available from your terminal. Install the Heroku CLI on your development machine.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |