百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

rails-recurly-subscription-saas

> 编程语言
开源

一个使用 Recurly 为会员或订阅网站提供定期计费的 Rails 3.2 应用程序示例。

170 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个使用 Recurly 为会员或订阅网站提供定期计费的 Rails 3.2 应用程序示例。

h1. !http://railsapps.github.io/images/rails-36x36.jpg(Rails Application for a Membership, Subscription, or SaaS Site)! Rails App for a Membership, Subscription, or SaaS Site with Recurly

Rails 3.2 example application with recurring billing using Recurly. Use for a Rails membership site, subscription site, or SaaS site (software-as-a-service). Using:

  • "Devise":http://github.com/plataformatec/devise authentication and user management
  • "CanCan":https://github.com/ryanb/cancan authorization for administrator access
  • "Twitter Bootstrap":http://twitter.github.com/bootstrap/ front-end framework for CSS styling
  • "Recurly":https://recurly.com/ for recurring billing and subscription management

You can build this application in only a few minutes using the "Rails Composer":http://railsapps.github.io/rails-composer/ tool.

!http://railsapps.github.io/images/rails-recurly-subscription-saas.png(Rails Application for a Membership, Subscription, or SaaS Site)!

h2. !http://twitter-badges.s3.amazonaws.com/t_logo-a.png(Follow on Twitter)!:http://www.twitter.com/rails_apps Follow on Twitter

Follow the project on Twitter: "@rails_apps":http://twitter.com/rails_apps. Please tweet some praise if you like what you've found.

h2. What Is Implemented -- and What Is Not

Membership sites restrict access to content such as articles, videos, or user forums. Software-as-a-service (SaaS) sites limit use of web-based software to paid subscribers. The revenue model is the same whether the site provides high-value content or software as a service: A visitor purchases a subscription and gains access to restricted areas of the site. Typically, the subscription is repurchased monthly through a service that provides recurring billing.

The example application provides a complete and fully functional membership site.

  • tiered pricing for multiple subscription plans
  • optional "free trial" subscription as well as free accounts using Recurly
  • uses Recurly for no local credit card storage
  • Recurly accepts credit card payments from customers in any country or currency
  • PCI compliance using the Recurly JavaScript library
  • Recurly handles recurring billing, retries if payment fails, and cancels subscription if retries fail
  • paid subscriptions are created only after a successful credit card transaction
  • subscribers can upgrade or downgrade subscription plans
  • subscribers can cancel subscription plans
  • configurable subscription renewal period (defaults to one month)
  • administrator can change subscription plan or delete user

h4. What is Not Implemented

There are additional features you may want for a SaaS application, such as:

  • Basecamp-style subdomains (each user gets their own subdomain)
  • "multitenancy":http://en.wikipedia.org/wiki/Multitenancy database segmentation

These features are not included in this application. See the "rails3-subdomains":https://github.com/RailsApps/rails3-subdomains example application for help with subdomains. For multitenancy, try Brad Robertson's "Apartment":https://github.com/bradrobertson/apartment gem.

h2. Similar Examples and Tutorials

h4. RailsApps

This is one in a series of Rails example apps and tutorials from the "RailsApps Project":http://railsapps.github.io/. See a list of additional "Rails examples, tutorials, and starter apps":http://railsapps.github.io/rails-examples-tutorials.html.

This example application is based on the "rails3-bootstrap-devise-cancan":https://github.com/RailsApps/rails3-bootstrap-devise-cancan starter application. This example application uses ActiveRecord and a SQLite database with RSpec and Cucumber for testing.

This application is similar to the "rails-stripe-membership-saas":https://github.com/RailsApps/rails-stripe-membership-saas application which provides recurring billing using the "Stripe":https://stripe.com/ billing service.

You might also be interested in the "rails-prelaunch-signup":https://github.com/RailsApps/rails-prelaunch-signup example and tutorial from the RailsApps project.

h4. Other Projects

  • Recurly's "recurly-client-ruby-demo":https://github.com/recurly/recurly-client-ruby-demo
  • Recurly's "recurly-client-ruby":https://github.com/recurly/recurly-client-ruby
  • Nick O'Neill's "recurly-rails":https://github.com/biznickman/recurly-rails

h2. Dependencies

Before generating your application, you will need:

  • The Ruby language (version 1.9.3 or 2.0.0)
  • The Rails gem (version 3.2.13)

See the article "Installing Rails":http://railsapps.github.io/installing-rails.html for advice about updating Rails and your development environment.

h2. Getting the Application

You have several options for getting the code. You can fork, clone, or generate.

h3. Fork

If you'd like to add features (or bug fixes) to improve the example application, you can fork the GitHub repo and "make pull requests":http://help.github.com/send-pull-requests/. Your code contributions are welcome!

h3. Clone

If you want to copy and customize the app with changes that are only useful for your own project, you can clone the GitHub repo. You'll need to search-and-replace the project name throughout the application. You probably should generate the app instead (see below). To clone:

$ git clone git://github.com/RailsApps/rails-recurly-subscription-saas.git

You'll need "git":http://git-scm.com/ on your machine. See "Rails and Git":http://railsapps.github.io/rails-git.html.

h3. Generate

If you want to use the project as a starter app, use the "Rails Composer":http://railsapps.github.io/rails-composer/ tool to generate a new version of the example app. You'll be able to give it your own project name when you generate the app. Generating the application gives you additional options.

To build the example application, run the command:

$ rails new rails-recurly-subscription-saas -m https://raw.github.com/RailsApps/rails-composer/master/composer-Rails3_2.rb -T

Use the @-T@ flag to skip Test::Unit files.

The @$@ character indicates a shell prompt; don't include it when you run the command.

This creates a new Rails app named @rails-recurly-subscription-saas@ on your computer. You can use a different name if you wish.

You'll see a prompt:

question Install an example application? 1) I want to build my own application 2) membership/subscription/saas 3) rails-prelaunch-signup 4) rails3-bootstrap-devise-cancan 5) rails3-devise-rspec-cucumber 6) rails3-mongoid-devise 7) rails3-mongoid-omniauth 8) rails3-subdomains

Choose membership/subscription/saas.

Then choose Recurly:

question Billing with Stripe or Recurly? 1) Stripe 2) Recurly

The application generator template will ask you for additional preferences:

question Web server for development? 1) WEBrick (default) 2) Thin 3) Unicorn 4) Puma question Web server for production? 1) Same as development 2) Thin 3) Unicorn 4) Puma question Template engine? 1) ERB 2) Haml 3) Slim extras Set a robots.txt file to ban spiders? (y/n) extras Use or create a project-specific rvm gemset? (y/n) extras Create a GitHub repository? (y/n)

h4. Web Servers

We recommend Thin in development for speed and less noise in the log files.

If you plan to deploy to Heroku, select Thin as your production webserver.

h4. Template Engine

The example application uses the default "ERB" Rails template engine. Optionally, you can use another template engine, such as Haml or Slim. See instructions for "Haml and Rails":http://railsapps.github.io/rails-haml.html.

h4. Other Choices

Set a robots.txt file to ban spiders if you want to keep your new site out of Google search results.

It is a good idea to use "rvm":https://rvm.io/, the Ruby Version Manager, and create a project-specific rvm gemset (not available on Windows). See "Installing Rails":http://railsapps.github.io/installing-rails.html.

If you choose to create a GitHub repository, the generator will prompt you for a GitHub username and password.

h4. Troubleshooting

If you get an error "OpenSSL certificate verify failed" or "Gem::RemoteFetcher::FetchError: SSL_connect" see the article "OpenSSL errors and Rails":http://railsapps.github.io/openssl-certificate-verify-failed.html.

If you get an error like this:

Your bundle is complete! Use bundle show [gemname] to see where a bundled gem is installed. composer Running 'after bundler' callbacks. The template [...] could not be loaded. Error: You have already activated ..., but your Gemfile requires .... Using bundle exec may solve this.

It's due to conflicting gem versions. See the article "Rails Error: “You have already activated (…)”":http://railsapps.github.io/rails-error-you-have-already-activated.html.

h3. Edit the README

If you're storing the app in a GitHub repository, please edit the README files to add a description of the app and your contact info. If you don't change the README, people will think I am the author of your version of the application.

h2. Getting Started

See the article "Installing Rails":http://railsapps.github.io/installing-rails.html to make sure your development environment is prepared properly.

h3. Recurly Account

The application implements recurring billing using "Recurly":https://recurly.com/. Before you start, go to the Recurly website and set up an account.

h3. Merchant Account

Your business will need a merchant account in order to accept credit card payments. Recurly does not include a merchant account as part of the service. If your business is established and already taking credit card payments, you will already have a merchant account. If not, you will have to obtain a merchant account. If you have a U.S.-based business, Recurly will refer you to their partner, "TSYS Merchant Solutions":http://www.tsysmerchantsolutions.com/mark/index.html, one of the largest credit card processors in the U.S., and a salesperson will contact you to send you an application form. It takes a few days to get approval so get the process started early.

h3. Use RVM

I recommend using "rvm":https://rvm.io/, the Ruby Version Manager, to create a project-specific gemset for the application. If you generate the application with the Rails Composer tool, you can create a project-specific gemset.

h3. Install the Required Gems

Check the Gemfile to see which gems are used by this application.

If you generate the application with the Rails Composer tool, all gems will be installed.

Otehrwise, run the @bundle install@ command to install the required gems on your computer:

$ bundle install

You can check which gems are installed on your computer with:

$ gem list

Keep in mind that you have installed these gems locally. When you deploy the app to another server, the same gems (and versions) must be available.

h3. Configure Email

You must configure the application for your email account. See the article "Send Email with Rails":http://railsapps.github.io/rails-send-email.html.

h3. Configure Devise

You can modify the configuration file for Devise if you want to use something other than the defaults:

  • config/initializers/devise.rb

h3. Configuration File

The application uses the "figaro gem":https://github.com/laserlemon/figaro to set environment variables. Credentials for your administrator account and Recurly API and cryptographic keys are set in the config/application.yml file. The .gitignore file prevents the config/application.yml file from being saved in the git repository so your credentials are kept private. See the article "Rails Environment Variables":http://railsapps.github.io/rails-environment-variables.html for more information.

Modify the file config/application.yml:

Add account credentials and API keys here.

See http://railsapps.github.io/rails-environment-variables.html

This file should be listed in .gitignore to keep your settings secret!

Each entry sets a local environment

Issues· 9 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言