diff --git a/source/includes/figures/quickstart-sinatra-list.png b/source/includes/figures/quickstart-sinatra-list.png new file mode 100644 index 00000000..8adc6c1c Binary files /dev/null and b/source/includes/figures/quickstart-sinatra-list.png differ diff --git a/source/quick-start-sinatra.txt b/source/quick-start-sinatra.txt index 11814e03..5b9e69c4 100644 --- a/source/quick-start-sinatra.txt +++ b/source/quick-start-sinatra.txt @@ -9,7 +9,7 @@ Quick Start (Sinatra) :values: tutorial .. meta:: - :keywords: php framework, odm + :keywords: ruby framework, odm .. contents:: On this page :local: @@ -58,7 +58,6 @@ that connects to a MongoDB deployment. /quick-start-sinatra/create-a-deployment/ /quick-start-sinatra/create-a-connection-string/ /quick-start-sinatra/configure-mongodb/ - -.. /quick-start-sinatra/view-data/ -.. /quick-start-sinatra/write-data/ -.. /quick-start-sinatra/next-steps/ + /quick-start-sinatra/view-data/ + /quick-start-sinatra/write-data/ + /quick-start-sinatra/next-steps/ diff --git a/source/quick-start-sinatra/next-steps.txt b/source/quick-start-sinatra/next-steps.txt new file mode 100644 index 00000000..d2c03d89 --- /dev/null +++ b/source/quick-start-sinatra/next-steps.txt @@ -0,0 +1,31 @@ +.. _mongoid-quick-start-sinatra-next-steps: + +========== +Next Steps +========== + +.. facet:: + :name: genre + :values: reference + +.. meta:: + :keywords: learn more + +Congratulations on completing the Quick Start tutorial for Sinatra! + +After you complete these steps, you have a Sinatra web application that +uses {+odm+} to connect to your MongoDB deployment, run a query on +the sample data, and render retrieved results. + +.. TODO You can download the completed web application project by cloning the +.. `mongoid-quickstart <>`__ +.. GitHub repository. + +.. TODO Learn more about {+odm+} features from the following resources: + +.. - :ref:`mongoid-fundamentals-connection`: Learn how to configure your MongoDB +.. connection. +.. +.. - :ref:`mongoid-usage-examples`: See code examples of frequently used MongoDB +.. operations. + diff --git a/source/quick-start-sinatra/view-data.txt b/source/quick-start-sinatra/view-data.txt new file mode 100644 index 00000000..8498eb4f --- /dev/null +++ b/source/quick-start-sinatra/view-data.txt @@ -0,0 +1,150 @@ +.. _mongoid-quick-start-sinatra-view-data: + +================= +View MongoDB Data +================= + +.. facet:: + :name: genre + :values: tutorial + +.. meta:: + :keywords: test connection, runnable, code example + +.. procedure:: + :style: connected + + .. step:: Create an application file + + At the root level of your project, create a file called ``app.rb``. + Paste the following contents into the ``app.rb`` file to + load the necessary gems and your configuration file: + + .. code-block:: ruby + + require 'sinatra' + require 'mongoid' + + Mongoid.load!(File.join(File.dirname(__FILE__), 'config', 'mongoid.yml')) + + .. step:: Create a data model + + In the ``app.rb`` file, create a model called ``Restaurant`` + to represent data from the sample ``restaurants`` collection in + the ``sample_restaurants`` database: + + .. code-block:: ruby + + class Restaurant + include Mongoid::Document + + field :name, type: String + field :cuisine, type: String + field :borough, type: String + + end + + .. step:: Generate a view + + Create a **view** to display your data in a specified way by using + HTML and {+language+}. + + At the root level of your project, create a directory + called ``views``. Then, create a file called + ``list_restaurants.erb``. Paste the following code into the + ``list_restaurants.erb`` file: + + .. code-block:: html + + + +
+Name | +Cuisine | +Borough | +
---|---|---|
<%= restaurant.name %> | +<%= restaurant.cuisine %> | +<%= restaurant.borough %> | +