Say that in your Rails app’s admin interface you have a table of orders, each of which is associated with a customer. You need to find orders belonging to a particular customer, by e-mail address. This is a search across two tables, orders and customers.

This is part 3 of building a gem for targeted, one-time announcements to users in Rails. See part 2 and part 1.

We’ll focus on targeting announcements to certain types of users. For instance, the admin may want to deliver an announcement only to users who have subscriptions.

A field in the Announcements table called limit_to_users will specify which types of users should receive the announcement.

limit_to_users can contain multiple conditions, so we’ll make it an array of hashes. ActiveRecord allows objects like these to be stored in text fields in the database, using the serialize method in a model.

1

2

app/models/announcement.rb

serialize:limit_to_users

This test validates that the field works as intended, storing conditions and allowing them to be retrieved. Here, we are sharing the announcement only with users who do not have a subscription.

In part 1, I talked about the need to announce things to users in a Rails app. The announcements should be scheduled, shown to each user only once, and targeted to particular types of users.

We’re building a Ruby gem to enable this.

Tests

I started by writing tests, describing what the one-time announcements gem should do. Test driven development (TDD) can be controversial, but I find that it helps me plan and identify issues earlier in development.

Sometimes we need to show tables of data in a Rails app, sort of like souped-up spreadsheets. The tables, or grids, should handle tons of records, support searching and filtering, and allow for customization.

Ever try coding a data grid yourself? It’s hard. You need to implement pagination, filtering, searching, ordering, etc., every time. Why not use a pre-built solution and built off of it instead?

Wice Grid is the quickest grid solution out there for Rails. It takes care of both the client and server. It’s not AJAX-y and gorgeous, but it’s functional and reliable.

At Cook Smarts, we used Wice Grid to improve the admin interface without leaping to a full-scale solution like Rails Admin.

For instance, Cook Smarts’ customers can purchase gift certificates for their friends. Site admins need to see all gift certificates and search for particular ones. The easiest way for them to do this is through a data grid.

Add the grid code to a controller method, with the model whose data should appear in the grid.

1

@gift_certificates_grid=initialize_grid(GiftCertificate)

Then, add the grid code to a view, referencing the grid you specified in the controller. Add columns, specifying the attribute as the field name in the database and the name as the text to appear in the header of the grid.

Most apps have an admin interface, a place where the developers and special users can make changes to the database.

Creating your own admin interface is time-consuming, and can take the focus away from developing user-facing features. Figuring that admin interfaces have similar needs, frameworks have emerged that help get your started.

With Rails Admin, you can edit your database on dev and production, in a user-friendly way, without coding your own admin interface.

Its closest competition is Active Admin, which I see as too complex for a convenience tool.

Quick start

Add this to your Gemfile:

1

2

gem'rails_admin'

In a terminal window, while inside the path of your app, run

1

2

railsgrails_admin:install

You now have an admin panel, located at http://yourapp.com/admin

Two essential steps remain.

One, make sure your models are defined correctly. Have you defined associations, like belongs_to, has_one, and has_many, as needed?

In closing

I love Markdown, and will use this tool whenever I need to maintain static, formatted content in my app.

Rolling out Markdown editing to end users is trickier, since many may not be familiar with it. However, allowing people to use Markdown is different from requiring it. If you allow Markdown in comments, for instance, place a note under your new comment field stating that Markdown is an option, and link to a quick reference.

When I first took an course on edX, I was struck by the power of online education. There I was, learning Ruby on Rails for free, taking the same curriculum from the same professors as a group of students at Berkeley. I watched videos from the instructors, took quizzes, completed assignments, and tracked my progress along the way.

The next wave of online education, I believe, will come from individual experts marketing online courses. Sean McCabe is a prime example. He holds a unique skill, hand lettering, and successfully marketed a course teaching others how to master the skill and build a business from it.

The first challenge to teaching online is, of course, developing content. Another is finding a place to host and sell that content.

This guide highlights tools available for hosting and selling online courses, aiming to at least cover the different categories available to course creators. The guide is aimed toward robust online courses that may include video, written material, quizzes, and discussion. (Simpler courses – containing eBooks and other static, downloadable content – could be sold through services like Gumroad, with no need for robust courseware.)

Core features

First, it’s important to highlight how tools differ.

Branding independence (B)Does the author retain control of the his or her brand within the course? This is particularly important to those who use their courses to sell other products, like consulting, or who plan to create a related suite of courses.

Content ownership (C)Does the course author maintain full ownership over content, including the ability to pull it from the tool and/or publish it elsewhere?

Course design (D)Can the author easily design a robust course, without custom code or advanced customization? This allows independent authors to focus on content, not technology.

Infrastructure control (I)Does the author retain control of content and users regardless of the uptime of external service providers? Does the course continue to exist if a service provider goes out of business?

Price control (P)
Can the author set and control the price of the course? Can others discount the price without asking the author?

User control (U)
Can the author reach out directly to course participants, on his or her own terms (assuming the course participants have agreed to such outreach)?

—

Now, for the tools…

Marketplaces

Core features: C-, D, P-, U-

Udemy and Skillshare are two examples of marketplaces. They allow anyone to set up and sell a course. They ask for no upfront fees from authors, host all course materials, and promote courses to a wide community of users. In exchange for these services, they take a cut of course revenue.

Marketplaces provide limited content ownership, price control, and user control. To find economy of scale, the services need to take something away from each of those elements. They’re centrally hosted and thus provide no infrastructure control. They take on the brand of the marketplace, so offer you no branding independence.

Authors maintain control over course content and retain ownership, but give up control over pricing. Both services apply their own discounts to courses (though may provide a way for authors to opt out), impacting revenue.

Sean McCabe shared his experiences with one such provider, in this podcast worth listening to if you are comparing your options. In short, he lost control over his content and pricing.

Subscription communities

Core features: D

Subscription communities like Lynda, Treehouse, and Learnable bundle courses into subscriptions. They provide the course author with no content, price, user, infrastructure, or branding control, but do provide rich course design tools. In exchange, they provide guaranteed payment to course authors.

The author receives an upfront payment and commissions based on the number of people who take the course (and often other factors).

Hosted tools

Core features: C, P, U, B-, D

Thinkific and similar tools provide full content, price, user control, and course design tools, but no infrastructure control. They generally charge monthly and transaction fees to course authors, their only revenue source.

They provide limited branding control, allowing you to place your own logo and styles on your course. Generally, though, it is somewhat clear that the course is hosted on their platform.

Self-hosted WordPress plugins

Core features: B, C, P, I-, U

WordPress has a number of plugins that allow people to sell content online. MemberMouse and Wishlist Member are two examples. These tools live on your own WordPress site, not on the service provider’s platform.

They provide full content, price, and user control. They provide full branding control, as you can customize your WordPress site to your heart’s content.

They do not provide complete infrastructure control. MemberMouse charges course authors a monthly fee, and phones home to ensure it’s collected. It’s not entirely clear what happens if that home goes away (i.e. MemberMouse goes out of business). MemberMouse also handles a few things on its own servers, like recurring billing.

Importantly, such tools are not courseware, per se. They take care of the business side of running an online course – that is, allowing people to purchase courses on a subscription or one-time basis – but do not provide the user interface for the course itself. It is up to the author to create the course within WordPress.

Custom development

Core features: C, P, U, I, B, D

There’s no beating the control you get with custom development, but it’s expensive. It’s worth listening to Sean McCabe’s take on what he went through to build his own platform, and the rewards he gained.

Open-source tools

In conclusion

There is a gap in the market for solid, affordable self-hosted solutions that would deliver all of the elements first identified in this article. In the mean time, authors are left to choose custom development or consider tools like those listed above.