Skip to content
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

Active Record tutorial #1234

Merged
merged 3 commits into from
Mar 31, 2017
Merged

Active Record tutorial #1234

merged 3 commits into from
Mar 31, 2017

Conversation

jseldess
Copy link
Contributor

@jseldess jseldess commented Mar 31, 2017

Expand Ruby "build an app" tutorial to offer usage of pg driver or Active Record ORM.

Fixes #547


This change is Reviewable

@jseldess jseldess requested a review from jordanlewis March 31, 2017 16:50
@jordanlewis
Copy link
Member

Generally looking good! except usually its spelled ActiveRecord, not Active Record


Review status: 0 of 8 files reviewed at latest revision, 8 unresolved discussions.


build-a-ruby-app-with-cockroachdb-activerecord.md, line 3 at r1 (raw file):

---
title: Build a Ruby App with CockroachDB
summary: Learn how to use CockroachDB from a simple Ruby application with the Active Record ORM.

ActiveRecord*


build-a-ruby-app-with-cockroachdb-activerecord.md, line 12 at r1 (raw file):

</div>

This tutorial shows you how build a simple Ruby application with CockroachDB using a PostgreSQL-compatible driver or ORM. We've tested and can recommend the [Ruby pg driver](https://rubygems.org/gems/pg) and the [Active Record ORM](http://guides.rubyonrails.org/active_record_basics.html), so those are featured here.

ActiveRecord*


build-a-ruby-app-with-cockroachdb-activerecord.md, line 14 at r1 (raw file):

This tutorial shows you how build a simple Ruby application with CockroachDB using a PostgreSQL-compatible driver or ORM. We've tested and can recommend the [Ruby pg driver](https://rubygems.org/gems/pg) and the [Active Record ORM](http://guides.rubyonrails.org/active_record_basics.html), so those are featured here.

{{site.data.alerts.callout_success}}For a more realistic use of Active Record with CockroachDB, see our <a href="https://github.com/cockroachdb/examples-orms"><code>examples-orms</code></a> repository.{{site.data.alerts.end}}

ActiveRecord*


build-a-ruby-app-with-cockroachdb-activerecord.md, line 24 at r1 (raw file):

## Step 1. Install the Active Record ORM

To install Active Record as well as the [pg driver](https://rubygems.org/gems/pg) and a [CockroachDB Ruby package](https://github.com/cockroachdb/activerecord-cockroachdb-adapter) that accounts for some minor differences between CockroachDB and PostgreSQL, run the following command:

This should be spelled ActiveRecord, not Active Record, throughout.


build-a-ruby-app-with-cockroachdb-activerecord.md, line 34 at r1 (raw file):

## Step 5. Run the Ruby code

The following code uses the [Active Record](http://guides.rubyonrails.org/active_record_basics.html) ORM to map Ruby-specific objects to SQL operations. Specifically, `Schema.new.change()` creates an `accounts` table based on the Account model (or drops and recreates the table if it already exists), `Account.create()` inserts rows into the table, and `Account.all.each` selects from the table so that balances can be printed.

ActiveRecord*

Remove the .each - the thing doing the selecting is just Account.all.


build-a-ruby-app-with-cockroachdb-activerecord.md, line 89 at r1 (raw file):

## What's Next?

Read more about using the [Active Record ORM](http://guides.rubyonrails.org/active_record_basics.html), or check out a more realistic implementation of Active Record with CockroachDB in our [`examples-orms`](https://github.com/cockroachdb/examples-orms) repository.

ActiveRecord*


build-a-ruby-app-with-cockroachdb.md, line 12 at r1 (raw file):

</div>

This tutorial shows you how build a simple Ruby application with CockroachDB using a PostgreSQL-compatible driver or ORM. We've tested and can recommend the [Ruby pg driver](https://rubygems.org/gems/pg) and the [Active Record ORM](http://guides.rubyonrails.org/active_record_basics.html), so those are featured here.

ActiveRecord*


build-an-app-with-cockroachdb.md, line 15 at r1 (raw file):

[Go](build-a-go-app-with-cockroachdb.html) | pq | GORM
[Python](build-a-python-app-with-cockroachdb.html) | psycopg2 | SQLAlchemy
[Ruby](build-a-ruby-app-with-cockroachdb.html) | pg | Active Record

ActiveRecord


Comments from Reviewable

@jseldess jseldess force-pushed the activerecord-tutorial branch from 2cdf315 to bafa977 Compare March 31, 2017 16:59
@jseldess
Copy link
Contributor Author

Review status: 0 of 8 files reviewed at latest revision, 8 unresolved discussions.


build-a-ruby-app-with-cockroachdb-activerecord.md, line 3 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

ActiveRecord*

Done.


build-a-ruby-app-with-cockroachdb-activerecord.md, line 12 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

ActiveRecord*

Done.


build-a-ruby-app-with-cockroachdb-activerecord.md, line 14 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

ActiveRecord*

Done.


build-a-ruby-app-with-cockroachdb-activerecord.md, line 24 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

This should be spelled ActiveRecord, not Active Record, throughout.

Done.


build-a-ruby-app-with-cockroachdb-activerecord.md, line 34 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

ActiveRecord*

Remove the .each - the thing doing the selecting is just Account.all.

Done.


build-a-ruby-app-with-cockroachdb-activerecord.md, line 89 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

ActiveRecord*

Done.


build-a-ruby-app-with-cockroachdb.md, line 12 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

ActiveRecord*

Done.


build-an-app-with-cockroachdb.md, line 15 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

ActiveRecord

Done.


Comments from Reviewable

@jseldess jseldess force-pushed the activerecord-tutorial branch from bafa977 to 5a78a9a Compare March 31, 2017 17:02
Once we commit to supporting additional ORMs,
we can add this bit back in.
@jseldess jseldess merged commit f597d35 into gh-pages Mar 31, 2017
@jseldess jseldess deleted the activerecord-tutorial branch March 31, 2017 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants