Document management system. Based on bill tracking needs. Simple model for stages, priorities, authors, content (abstract, tags), releated docs, and full text search in the all docs and related docs. in It's part of POPLUS environment.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Bill management system for the Poplus project.


Make sure you have ruby 2.0 and bundler installed. If not visit and

Make sure you have mongodb installed if not follow instructions at

Java is needed for Solr. OpenJDK 7 is the recommended package. In Debian / Ubuntu run

apt-get install openjdk-7-jdk

clone the billit project

git clone

go to the bill-it project folder install gems

bundle install

create all config files, and modify according to server

cp config/sunspot.yml.example config/sunspot.yml
cp config/mongoid.yml.example config/mongoid.yml
cp config/hateoas.yml.example config/hateoas.yml

start solr for search indexing

bundle exec rake sunspot:solr:start

make sure solr is running. Type the following url in your browser:


run the service:

bundle exec rails s

If you are running a development environment and you want to monitor file changes and respond immediately, then run this instead:

bundle exec guard

visit http://localhost:3000 to see billit running

Deploying to production

Tasks using cron

To run tasks like send notifications emails of changes in bills the project use whenever, this tool generate cron jobs from the config/schedule.rb file.

Add the jobs to crontab:

bundle exec whenever --update-crontab bill-it

Clear the jobs associated with a app name:

bundle exec whenever --clear-crontab bill-it

##Usage ###GET bill

  • /bills/id.json => bill by id in json format
  • /bills/id.json?callback=my_function => bill by id in jsonp format, with my_function as wrapper funcition
  • /bills/id.xml => bill by id in xml format
  • /bills/new => create a new bill by filling in a form
  • /bills/id/edit => edit bill

###GET search

  • /bills/search.json?q=term => search for "term" in all fields
  • /bills/search.json?q=term&callback=my_function => search for "term" in jsonp format, with my_function as wrapper funcition
  • /bills/search.json?title=hello|hola&tags=world => search for bills with title similar to "hello" or "hola" and with the tag "world"

####Example from the app's search:

  • /bills/search?utf8=✓q=&bill_id=&authors=&stage=&initial_chamber=&current_priority=&creation_date_min=2010-10-10&creation_date_max=2014-09-16&bills=1


  • /bills => creates new bill


  • /bills/id => modifies bill


  • /bills/id => deletes bill

##ROAR usage (the nice way) For info of how ROAR works go to Essentially, you can work on your application as if you had local objects, when they're really in another server

require gems "billit_representers" and "roar" in your local project, or add them to your gemfile

gem 'billit_representers'
gem 'roar'

###Bills extend your local model. Example model:

require 'roar/representer/feature/client'
require 'billit_representers/representers/bill_representer'

class Bill
  include Roar::Representer::Feature::HttpVerbs

  def initialize(*)
    extend Billit::BillRepresenter
    extend Roar::Representer::Feature::Client
    # transport_engine = Roar::Representer::Transport::Faraday
    @persisted = true if @persisted.nil?

GET bill

bill =
bill.get('', 'application/json')

POST (create new bill)

bill =
bill.uid = '0-00'
bill.title = 'new title''')

PUT (modify existing bill)

bill =
bill.get('', 'application/json')
bill.put('', 'application/json')

###Bill Collections extend your local page model. Example model:

require 'billit_representers/representers/bill_collection_page_representer'

class BillCollectionPage < OpenStruct
  include Roar::Representer::Feature::HttpVerbs

  def initialize
    extend Billit::BillCollectionPageRepresenter
    extend Roar::Representer::Feature::Client
    transport_engine = Roar::Representer::Transport::Faraday

  def self
    links[:self].href if links[:self]

  def next
    links[:next].href if links[:next]

  def previous
    links[:previous].href if links[:previous]

GET search

bill_page =
bill_page.get('', 'application/json')
#bill array
bill_array = bill_page.bills
#next page
bill_next_page =
bill_next_page.get(, 'application/json')


If you add information, like bills, through the post or put method, it gets automatically reindexed. If you add them manually or through the database the indexing has to be done manually. This can be done by executing the rails console

bundle exec rails console

and then executing the reindex method on your model name, for instance:

Sunspot.index! Bills.all 

In this method you can actually write any query instead of Bills.all and it will only reindex that query.

There are other commands that perform a reindexing, but they can be resource intensive and not so granular:

bundle exec rake sunspot:solr:reindex

The bundle exec command needs to have the ENV variable set, you can just run it as this:

ENV=production bundle exec rails console

Change production for development or test, depending on the environment you want to run the console in.



How to deploy as an permanent service

If you want to configure BillIt as a service, once way of doing it is with nginx and passenger

gem install passenger 

Follow the instructions here:

Step 2.3 is the only thing needed. Or 2.4 for Fedora.

WARNING: If you have the project installed in it's own user folder (eg: /home/billit) and you have bundles installed in vendor/bundle, then setting a global passenger_ruby interpreter in the nginx.conf file will prevent the interpreter from finding the correct bundle. So please comment out the passenger_ruby in nginx.conf

Then you need to add the application to nginx, here you have a sample configuration file: