|
| 1 | +.. _mongoid-quick-start-rails-download-and-install: |
| 2 | + |
| 3 | +==================== |
| 4 | +Download and Install |
| 5 | +==================== |
| 6 | + |
| 7 | +.. facet:: |
| 8 | + :name: genre |
| 9 | + :values: tutorial |
| 10 | + |
| 11 | +.. meta:: |
| 12 | + :keywords: ruby framework, odm, code example |
| 13 | + |
| 14 | +Prerequisites |
| 15 | +------------- |
| 16 | + |
| 17 | +To create the Quick Start application by using Ruby on Rails 7, you need the |
| 18 | +following software installed in your development environment: |
| 19 | + |
| 20 | +- `{+language+}. <https://www.ruby-lang.org/en/documentation/installation/>`__ |
| 21 | + Rails requires {+language+} v3.1.0 or later. Use the latest version |
| 22 | + to prevent version conflicts. |
| 23 | +- `RubyGems package manager. <https://rubygems.org/pages/download>`__ |
| 24 | +- A terminal app and shell. For MacOS users, use Terminal or a similar app. |
| 25 | + For Windows users, use PowerShell. |
| 26 | + |
| 27 | +.. tip:: Rails 6 Tutorial |
| 28 | + |
| 29 | + If you prefer to use Rails 6 to build your application, see the |
| 30 | + :ref:`mongoid-getting-started-rails-6` guide. |
| 31 | + |
| 32 | +Download and Install the {+odm+} and Framework Gems |
| 33 | +--------------------------------------------------- |
| 34 | + |
| 35 | +In {+language+}, packages are called **gems**. |
| 36 | + |
| 37 | +Complete the following steps to install and add the {+odm+} and Rails |
| 38 | +gems to your web application. |
| 39 | + |
| 40 | +.. procedure:: |
| 41 | + :style: connected |
| 42 | + |
| 43 | + .. step:: Install Rails |
| 44 | + |
| 45 | + Install the ``rails`` gem, which provides a command-line |
| 46 | + interface to create a basic application structure and application |
| 47 | + components. |
| 48 | + |
| 49 | + Run the following command to install ``rails``: |
| 50 | + |
| 51 | + .. code-block:: bash |
| 52 | + |
| 53 | + gem install rails |
| 54 | + |
| 55 | + .. step:: Create a Rails app with default scaffolding |
| 56 | + |
| 57 | + Run the following commands to create a new Rails application |
| 58 | + directory with default scaffolding and enter the application: |
| 59 | + |
| 60 | + .. code-block:: bash |
| 61 | + |
| 62 | + rails new {+quickstart-rails-app-name+} --skip-active-record |
| 63 | + cd {+quickstart-rails-app-name+} |
| 64 | + |
| 65 | + The ``--skip-active-record`` flag instructs Rails to not add |
| 66 | + ``ActiveRecord`` as a dependency. You don't need this |
| 67 | + dependency because you will use {+odm+} |
| 68 | + instead. |
| 69 | + |
| 70 | + .. tip:: MacOS Installation Issue |
| 71 | + |
| 72 | + If you are using macOS, you might encounter issues when creating a |
| 73 | + new Rails app during the automatic bundle installation step. |
| 74 | + First, make sure that your macOS and `Xcode |
| 75 | + <https://developer.apple.com/xcode/>`__ versions are up to |
| 76 | + date. If you receive an error message similar to the following, |
| 77 | + you must update or configure your build tools: |
| 78 | + |
| 79 | + .. code-block:: none |
| 80 | + :copyable: false |
| 81 | + |
| 82 | + The compiler failed to generate an executable file. |
| 83 | + ... |
| 84 | + (RuntimeError) You have to install development tools first. |
| 85 | + |
| 86 | + Run the following commands to install Xcode command line tools: |
| 87 | + |
| 88 | + .. code-block:: bash |
| 89 | + |
| 90 | + xcode-select --install |
| 91 | + xcodebuild -license accept |
| 92 | + |
| 93 | + Then, try to run the ``bundle install`` command again. |
| 94 | + |
| 95 | + .. step:: Add the {+odm+} gem |
| 96 | + |
| 97 | + Open the ``Gemfile`` in your application and add the following |
| 98 | + entry: |
| 99 | + |
| 100 | + .. code-block:: ruby |
| 101 | + |
| 102 | + gem 'mongoid' |
| 103 | + |
| 104 | + .. step:: Install gems |
| 105 | + |
| 106 | + Run the following command to install the gems into your |
| 107 | + application: |
| 108 | + |
| 109 | + .. code-block:: bash |
| 110 | + |
| 111 | + gem install bundler |
| 112 | + bundle install |
| 113 | + |
| 114 | + When the command runs successfully, the output in your |
| 115 | + shell contains a ``Bundle complete!`` message and describes the |
| 116 | + number of new gems installed. |
| 117 | + |
| 118 | + After completing these steps, you have a new Rails web application with |
| 119 | + {+odm+} installed. |
| 120 | + |
| 121 | +.. include:: /includes/quick-start/troubleshoot.rst |
0 commit comments