-
Notifications
You must be signed in to change notification settings - Fork 4
Updated Ruby on Rails docs #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…8080 to 3000 for local application and Swagger documentation access.
…me, install additional gem, and reflect port change to 3000 for application and Swagger documentation access.
tutorial/markdown/ruby/ruby-on-rails/quickstart-ruby-on-rails.md
Outdated
Show resolved
Hide resolved
tutorial/markdown/ruby/ruby-on-rails/quickstart-ruby-on-rails.md
Outdated
Show resolved
Hide resolved
tutorial/markdown/ruby/ruby-on-rails/quickstart-ruby-on-rails.md
Outdated
Show resolved
Hide resolved
tutorial/markdown/ruby/ruby-on-rails/quickstart-ruby-on-rails.md
Outdated
Show resolved
Hide resolved
tutorial/markdown/ruby/ruby-on-rails/quickstart-ruby-on-rails.md
Outdated
Show resolved
Hide resolved
tutorial/markdown/ruby/ruby-on-rails/quickstart-ruby-on-rails.md
Outdated
Show resolved
Hide resolved
tutorial/markdown/ruby/ruby-on-rails/quickstart-ruby-on-rails.md
Outdated
Show resolved
Hide resolved
tutorial/markdown/ruby/ruby-on-rails/quickstart-ruby-on-rails.md
Outdated
Show resolved
Hide resolved
tutorial/markdown/ruby/ruby-on-rails/quickstart-ruby-on-rails.md
Outdated
Show resolved
Hide resolved
|
||
The application uses the following gems and needs to be installed globally even though they are specified in the `Gemfile`. | ||
|
||
```shell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use bundle install package manager not gem install for each dependency.
|
||
Once the application starts, you can see the details of the application on the logs. | ||
|
||
 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use relative path, so the image does not breaks in the PR
|
||
## Data Model | ||
|
||
For this tutorial, we use three collections, `airport`, `airline` and `route` that contain sample airports, airlines and airline routes respectively. The route collection connects the airports and airlines as seen in the figure below. We use these connections in the quickstart to generate airports that are directly connected and airlines connecting to a destination airport. Note that these are just examples to highlight how you can use SQL++ queries to join the collections. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use relative path, so the image does not breaks in the PR
|
||
We have the Couchbase SDK operations defined in the `CouchbaseClient` class inside the `config/initializers/couchbase.rb` file. | ||
|
||
We recommend creating a single Couchbase connection when your application starts up, and sharing this instance throughout your application. If you know at startup time which buckets, scopes, and collections your application will use, we recommend obtaining them from the Cluster at startup time and sharing those instances throughout your application as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what meant by this
|
||
We recommend creating a single Couchbase connection when your application starts up, and sharing this instance throughout your application. If you know at startup time which buckets, scopes, and collections your application will use, we recommend obtaining them from the Cluster at startup time and sharing those instances throughout your application as well. | ||
|
||
In this application, we have created the connection object in `config/initializers/couchbase.rb` and we use this object in all of our APIs. The object is initialized in `config/initializers/couchbase.rb`. We have also stored the reference to our bucket, `travel-sample` and the scope, `inventory` in the connection object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this line is repeated "The object is initialized in `config/initializers/couchbase.rb"
also below paragraph taks the same
Inn the above code, we first create an instance of the `Airline` class using the `update` method. We pass the ID and the airline data to the `update` method. If the airline is updated successfully, we return the airline document with a status of 200. If there are any missing fields in the request, we return a bad request status of 400. If there is any other error, we return an internal server error status of 500. | ||
|
||
```rb | ||
def update(id, attributes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be consistant with create
Navigate to the `destroy` method in the `AirlinesController` class in the `airlines_controller.rb` file. We only need the airline document ID or our key from the user to delete a particular airline document using a key-value operation which is passed in the `destroy` method. | ||
|
||
```rb | ||
# DELETE /api/v1/airlines/{id} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be consistant with create
|
||
```rb | ||
# GET /api/v1/airlines/list | ||
def index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be consistant with create
|
||
## Running Tests | ||
|
||
We have defined integration tests using [RSpec](https://rspec.info/) for all the API end points. The integration tests use the same database configuration as the application. For the tests, we perform the operation using the API and confirm the results by checking the documents in the database. For example, to check the creation of the document by the API, we would call the API to create the document and then read the same document directly from the database using the CouchbaseClient and compare them. After the tests, the documents are cleaned up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just provide a single command to run all the tests , also flow other tutorials
If you would like to add another entity to the APIs, these are the steps to follow: | ||
|
||
- Create the new entity (collection) in the Couchbase bucket. You can create the collection using the [SDK](https://docs.couchbase.com/sdk-api/couchbase-ruby-client/Couchbase/Collection.html#create_collection-instance_method) or via the [Couchbase Server interface](https://docs.couchbase.com/server/current/manage/manage-settings/manage-collections.html). | ||
- Define the routes in a new file in the `api` folder similar to the existing routes like `airline_controller.rb`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this statement is workong properly explain where to add route, controller and model logic
No description provided.