├── log └── .keep ├── app ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── concerns │ │ └── .keep │ ├── invoice.rb │ └── listing.rb ├── assets │ ├── images │ │ ├── .keep │ │ └── background.jpg │ ├── stylesheets │ │ ├── foundation_and_overrides.scss │ │ ├── invoices.css.scss │ │ ├── listings.css.scss │ │ ├── form_hints.css.scss │ │ ├── application.css │ │ └── pages.css.scss │ └── javascripts │ │ ├── pages.js.coffee │ │ ├── invoices.js.coffee │ │ ├── listings.js.coffee │ │ └── application.js ├── controllers │ ├── concerns │ │ └── .keep │ ├── pages_controller.rb │ ├── application_controller.rb │ ├── invoices_controller.rb │ └── listings_controller.rb ├── helpers │ ├── pages_helper.rb │ ├── invoices_helper.rb │ ├── listings_helper.rb │ └── application_helper.rb └── views │ ├── layouts │ ├── _nav_items.html.haml │ ├── _header.html.haml │ └── application.html.haml │ ├── invoices │ └── show.html.haml │ ├── pages │ └── home.html.haml │ └── listings │ ├── show.html.haml │ └── new.html.haml ├── lib ├── assets │ └── .keep ├── tasks │ └── .keep └── templates │ └── haml │ └── scaffold │ └── _form.html.haml ├── public ├── favicon.ico ├── system │ └── listings │ │ └── files │ │ └── 000 │ │ └── 000 │ │ ├── 001 │ │ └── original │ │ │ └── chrome_frame_helper.exe │ │ ├── 002 │ │ └── original │ │ │ └── art-therapy-career2.jpg │ │ └── 003 │ │ └── original │ │ └── art-therapy-career2.jpg ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── test ├── helpers │ ├── .keep │ ├── pages_helper_test.rb │ ├── invoices_helper_test.rb │ └── listings_helper_test.rb ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── invoice_test.rb │ └── listing_test.rb ├── controllers │ ├── .keep │ ├── pages_controller_test.rb │ ├── invoices_controller_test.rb │ └── listings_controller_test.rb ├── fixtures │ ├── .keep │ ├── invoices.yml │ └── listings.yml ├── integration │ └── .keep └── test_helper.rb ├── vendor └── assets │ ├── javascripts │ └── .keep │ └── stylesheets │ └── .keep ├── bin ├── rake ├── bundle └── rails ├── config.ru ├── config ├── initializers │ ├── session_store.rb │ ├── filter_parameter_logging.rb │ ├── mime_types.rb │ ├── backtrace_silencers.rb │ ├── wrap_parameters.rb │ ├── secret_token.rb │ ├── inflections.rb │ ├── simple_form_foundation.rb │ ├── friendly_id.rb │ └── simple_form.rb ├── environment.rb ├── boot.rb ├── routes.rb ├── database.yml ├── locales │ ├── en.yml │ └── simple_form.en.yml ├── application.rb └── environments │ ├── development.rb │ ├── test.rb │ └── production.rb ├── db ├── migrate │ ├── 20131208002027_add_session_id_to_invoice.rb │ ├── 20131207235911_add_slug_to_invoice.rb │ ├── 20131207231811_create_invoices.rb │ ├── 20131207190926_add_attachment_file_to_listings.rb │ ├── 20131207231916_add_attachment_file_to_invoices.rb │ ├── 20131207190900_create_listings.rb │ └── 20131207235839_create_friendly_id_slugs.rb ├── seeds.rb └── schema.rb ├── Rakefile ├── README.md ├── .gitignore ├── LICENSE ├── Gemfile └── Gemfile.lock /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/helpers/pages_helper.rb: -------------------------------------------------------------------------------- 1 | module PagesHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/invoices_helper.rb: -------------------------------------------------------------------------------- 1 | module InvoicesHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/listings_helper.rb: -------------------------------------------------------------------------------- 1 | module ListingsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/assets/stylesheets/foundation_and_overrides.scss: -------------------------------------------------------------------------------- 1 | @import 'foundation'; 2 | -------------------------------------------------------------------------------- /app/assets/images/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachlatta/bitroad/HEAD/app/assets/images/background.jpg -------------------------------------------------------------------------------- /app/controllers/pages_controller.rb: -------------------------------------------------------------------------------- 1 | class PagesController < ApplicationController 2 | def home 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby.exe 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /app/views/layouts/_nav_items.html.haml: -------------------------------------------------------------------------------- 1 | %li= link_to "Home", root_path 2 | %li= link_to "Create Listing", new_listing_path -------------------------------------------------------------------------------- /test/helpers/pages_helper_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PagesHelperTest < ActionView::TestCase 4 | end 5 | -------------------------------------------------------------------------------- /test/helpers/invoices_helper_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class InvoicesHelperTest < ActionView::TestCase 4 | end 5 | -------------------------------------------------------------------------------- /test/helpers/listings_helper_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ListingsHelperTest < ActionView::TestCase 4 | end 5 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby.exe 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby.exe 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /test/models/invoice_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class InvoiceTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/models/listing_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ListingTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Bitroad::Application.config.session_store :cookie_store, key: '_bitroad_session' 4 | -------------------------------------------------------------------------------- /test/fixtures/invoices.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html 2 | 3 | one: 4 | completed: false 5 | 6 | two: 7 | completed: false 8 | -------------------------------------------------------------------------------- /app/views/invoices/show.html.haml: -------------------------------------------------------------------------------- 1 | - provide(:title, "Invoice") 2 | 3 | .row 4 | %h1= "Invoice ##{ @invoice.id }" 5 | = link_to "Download", @invoice.file.url, class: "button", "download" => "" -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Bitroad::Application.initialize! 6 | -------------------------------------------------------------------------------- /db/migrate/20131208002027_add_session_id_to_invoice.rb: -------------------------------------------------------------------------------- 1 | class AddSessionIdToInvoice < ActiveRecord::Migration 2 | def change 3 | add_column :invoices, :session_id, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | # Set up gems listed in the Gemfile. 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | 4 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) 5 | -------------------------------------------------------------------------------- /public/system/listings/files/000/000/001/original/chrome_frame_helper.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachlatta/bitroad/HEAD/public/system/listings/files/000/000/001/original/chrome_frame_helper.exe -------------------------------------------------------------------------------- /public/system/listings/files/000/000/002/original/art-therapy-career2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachlatta/bitroad/HEAD/public/system/listings/files/000/000/002/original/art-therapy-career2.jpg -------------------------------------------------------------------------------- /public/system/listings/files/000/000/003/original/art-therapy-career2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachlatta/bitroad/HEAD/public/system/listings/files/000/000/003/original/art-therapy-career2.jpg -------------------------------------------------------------------------------- /app/views/pages/home.html.haml: -------------------------------------------------------------------------------- 1 | %section.homepage-hero 2 | .row 3 | .medium-10.large-11.columns 4 | %h1 Bitroad 5 | %br.hide-for-small 6 | %h3 Sell anything online, safely and anonymously. -------------------------------------------------------------------------------- /app/assets/stylesheets/invoices.css.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the invoices controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/listings.css.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the listings controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /db/migrate/20131207235911_add_slug_to_invoice.rb: -------------------------------------------------------------------------------- 1 | class AddSlugToInvoice < ActiveRecord::Migration 2 | def change 3 | add_column :invoices, :slug, :string 4 | add_index :invoices, :slug, unique: true 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /test/controllers/pages_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class PagesControllerTest < ActionController::TestCase 4 | test "should get home" do 5 | get :home 6 | assert_response :success 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /test/controllers/invoices_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class InvoicesControllerTest < ActionController::TestCase 4 | test "should get show" do 5 | get :show 6 | assert_response :success 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | # Mime::Type.register_alias "text/html", :iphone 6 | -------------------------------------------------------------------------------- /app/assets/javascripts/pages.js.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/invoices.js.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/listings.js.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /app/assets/stylesheets/form_hints.css.scss: -------------------------------------------------------------------------------- 1 | .field_with_hint { 2 | input { 3 | margin-bottom: 0.6rem; 4 | } 5 | } 6 | 7 | span.hint { 8 | display: block; 9 | margin-bottom: 18px; 10 | color: rgb(115, 115, 115); 11 | font-size: 14px; 12 | } 13 | -------------------------------------------------------------------------------- /db/migrate/20131207231811_create_invoices.rb: -------------------------------------------------------------------------------- 1 | class CreateInvoices < ActiveRecord::Migration 2 | def change 3 | create_table :invoices do |t| 4 | t.boolean :completed 5 | t.belongs_to :listing 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Bitroad::Application.load_tasks 7 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | # Returns the full title on a per-page basis 3 | def full_title(page_title) 4 | base_title = "Bitroad" 5 | if page_title.empty? 6 | base_title 7 | else 8 | "#{ page_title } | #{ base_title }" 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20131207190926_add_attachment_file_to_listings.rb: -------------------------------------------------------------------------------- 1 | class AddAttachmentFileToListings < ActiveRecord::Migration 2 | def self.up 3 | change_table :listings do |t| 4 | t.attachment :file 5 | end 6 | end 7 | 8 | def self.down 9 | drop_attached_file :listings, :file 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20131207231916_add_attachment_file_to_invoices.rb: -------------------------------------------------------------------------------- 1 | class AddAttachmentFileToInvoices < ActiveRecord::Migration 2 | def self.up 3 | change_table :invoices do |t| 4 | t.attachment :file 5 | end 6 | end 7 | 8 | def self.down 9 | drop_attached_file :invoices, :file 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/views/listings/show.html.haml: -------------------------------------------------------------------------------- 1 | - provide(:title, @listing.name) 2 | 3 | .row 4 | %h1= @listing.name 5 | - if @listing.description 6 | %p= @listing.description 7 | %p= "Price: #{ @listing.price } BTC" 8 | = simple_form_for @listing, url: purchase_listing_path do |f| 9 | = f.button :submit, "Purchase" 10 | -------------------------------------------------------------------------------- /db/migrate/20131207190900_create_listings.rb: -------------------------------------------------------------------------------- 1 | class CreateListings < ActiveRecord::Migration 2 | def change 3 | create_table :listings do |t| 4 | t.string :name 5 | t.text :description 6 | t.decimal :price 7 | t.string :bitcoin_address 8 | 9 | t.timestamps 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /test/fixtures/listings.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html 2 | 3 | one: 4 | name: MyString 5 | description: MyText 6 | price: 9.99 7 | bitcoin_address: MyString 8 | 9 | two: 10 | name: MyString 11 | description: MyText 12 | price: 9.99 13 | bitcoin_address: MyString 14 | -------------------------------------------------------------------------------- /test/controllers/listings_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ListingsControllerTest < ActionController::TestCase 4 | test "should get new" do 5 | get :new 6 | assert_response :success 7 | end 8 | 9 | test "should get show" do 10 | get :show 11 | assert_response :success 12 | end 13 | 14 | end 15 | -------------------------------------------------------------------------------- /lib/templates/haml/scaffold/_form.html.haml: -------------------------------------------------------------------------------- 1 | = simple_form_for(@<%= singular_table_name %>) do |f| 2 | = f.error_notification 3 | 4 | .form-inputs 5 | <%- attributes.each do |attribute| -%> 6 | = f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> 7 | <%- end -%> 8 | 9 | .form-actions 10 | = f.button :submit 11 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Bitroad::Application.routes.draw do 2 | resources :listings do 3 | member do 4 | patch "purchase" 5 | end 6 | end 7 | 8 | resources :invoices 9 | 10 | get "home", to: redirect("/") 11 | 12 | root to: "pages#home" 13 | 14 | %w[home].each do |page| 15 | get page, controller: "pages", action: page 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | -------------------------------------------------------------------------------- /app/models/invoice.rb: -------------------------------------------------------------------------------- 1 | class Invoice < ActiveRecord::Base 2 | extend FriendlyId 3 | friendly_id :code, use: :slugged 4 | 5 | belongs_to :listing 6 | has_attached_file :file 7 | 8 | validates :file, presence: true 9 | validates :session_id, presence: true 10 | 11 | private 12 | 13 | def code 14 | Digest::SHA1.hexdigest self.file.url 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/views/listings/new.html.haml: -------------------------------------------------------------------------------- 1 | - provide(:title, "Create Listing") 2 | 3 | .row 4 | .large-6.columns 5 | %h1 Create Listing 6 | = simple_form_for @listing do |f| 7 | = f.input :name 8 | = f.input :description 9 | = f.input :file 10 | = f.input :price, label: "Price (in BTC)", 11 | hint: "10% of every purchase goes to a Bitcoin-accepting charity." 12 | = f.input :bitcoin_address 13 | = f.button :submit 14 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /app/controllers/invoices_controller.rb: -------------------------------------------------------------------------------- 1 | require "coinbase" 2 | 3 | class InvoicesController < ApplicationController 4 | def show 5 | @invoice = Invoice.friendly.find(params[:id]) 6 | if !@invoice.completed 7 | coinbase = Coinbase::Client.new(Figaro.env.coinbase_secret) 8 | coinbase.send_money @invoice.listing.bitcoin_address, @invoice.listing.price * 0.9 9 | @invoice.update_attributes!(completed: true) 10 | elsif @invoice.session_id != request.session_options[:id] 11 | redirect_to root_path 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] ||= "test" 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | ActiveRecord::Migration.check_pending! 7 | 8 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 9 | # 10 | # Note: You'll currently still have to declare fixtures explicitly in integration tests 11 | # -- they do not yet inherit this setting 12 | fixtures :all 13 | 14 | # Add more helper methods to be used by all tests here... 15 | end 16 | -------------------------------------------------------------------------------- /app/views/layouts/_header.html.haml: -------------------------------------------------------------------------------- 1 | %nav.top-bar.hide-for-small{"data-topbar" => ""} 2 | %ul.title-area 3 | %li.name 4 | %h1 5 | %a{:href => "/"} Bitroad 6 | %section.top-bar-section 7 | %ul.right 8 | = render "layouts/nav_items" 9 | %nav.tab-bar.show-for-small 10 | %section.left-small 11 | %a.left-off-canvas-toggle.menu-icon 12 | %span 13 | %section.middle.tab-bar-section 14 | %h1.title Bitroad 15 | %aside.left-off-canvas-menu 16 | %ul.off-canvas-list 17 | %li 18 | %label Navigation 19 | = render "layouts/nav_items" -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bitroad 2 | 3 | Bitroad is an online marketplace that lets anyone sell anything safely and anonymously online. It was created in under 7 hours for the Virtual Piggy 2013 hackathon. It won grand prize for the age 16-19 division. 4 | 5 | Bitroad is no longer maintained. If you're interested in taking over the project, please open an issue :smile:. 6 | 7 | ## Usage 8 | 9 | 1. Go to the website 10 | 2. Create a listing 11 | 3. Share the listing's link with anyone online 12 | 4. Anyone with the link can easily purchase the listing with bitcoin 13 | 14 |  15 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters) 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html{:lang => "en"} 3 | %head 4 | %meta{:charset => "utf-8"}/ 5 | %meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}/ 6 | %title= full_title(yield(:title)) 7 | = stylesheet_link_tag "application" 8 | = javascript_include_tag "vendor/modernizr" 9 | = csrf_meta_tags 10 | %body 11 | .off-canvas-wrap 12 | .inner-wrap 13 | = render "layouts/header" 14 | %section.main-section 15 | = yield 16 | %a.exit-off-canvas 17 | = javascript_include_tag "application" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/*.log 16 | /tmp 17 | 18 | # Paperclip 19 | /public/system 20 | # Ignore application configuration 21 | /config/application.yml 22 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the top of the 9 | * compiled file, but it's generally better to create a new file per style scope. 10 | * 11 | *= require_self 12 | *= require foundation_and_overrides 13 | 14 | *= require_tree . 15 | */ 16 | -------------------------------------------------------------------------------- /db/migrate/20131207235839_create_friendly_id_slugs.rb: -------------------------------------------------------------------------------- 1 | class CreateFriendlyIdSlugs < ActiveRecord::Migration 2 | def change 3 | create_table :friendly_id_slugs do |t| 4 | t.string :slug, :null => false 5 | t.integer :sluggable_id, :null => false 6 | t.string :sluggable_type, :limit => 50 7 | t.string :scope 8 | t.datetime :created_at 9 | end 10 | add_index :friendly_id_slugs, :sluggable_id 11 | add_index :friendly_id_slugs, [:slug, :sluggable_type] 12 | add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], :unique => true 13 | add_index :friendly_id_slugs, :sluggable_type 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | development: 7 | adapter: sqlite3 8 | database: db/development.sqlite3 9 | pool: 5 10 | timeout: 5000 11 | 12 | # Warning: The database defined as "test" will be erased and 13 | # re-generated from your development database when you run "rake". 14 | # Do not set this db to the same as development or production. 15 | test: 16 | adapter: sqlite3 17 | database: db/test.sqlite3 18 | pool: 5 19 | timeout: 5000 20 | 21 | production: 22 | adapter: sqlite3 23 | database: db/production.sqlite3 24 | pool: 5 25 | timeout: 5000 26 | -------------------------------------------------------------------------------- /app/models/listing.rb: -------------------------------------------------------------------------------- 1 | require 'bitcoin' 2 | 3 | class Listing < ActiveRecord::Base 4 | has_attached_file :file 5 | has_many :invoices 6 | 7 | validate :valid_bitcoin_address 8 | validates :name, presence: true 9 | validates :description, length: { maximum: 500 } 10 | validates :file, presence: true 11 | validates :price, presence: true, numericality: { greater_than: 0.005, 12 | less_than: 0.05 } 13 | validates :bitcoin_address, presence: true 14 | 15 | private 16 | 17 | def valid_bitcoin_address 18 | if !Bitcoin::valid_address?(bitcoin_address) 19 | errors.add(:bitcoin_address, "must be valid") 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rake secret` to generate a secure secret key. 9 | 10 | # Make sure your secret_key_base is kept private 11 | # if you're sharing your code publicly. 12 | Bitroad::Application.config.secret_key_base = '0bcfc94d605d63ec905c1bb20912c42ad7d3b952fed6aae2846e0234431feddeba4f322081509b3a215ca0b4d70c2db324a2599896139e188a5c29f80e6abfda' 13 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. 9 | // 10 | // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require jquery 14 | //= require jquery_ujs 15 | //= require foundation 16 | //= require turbolinks 17 | //= require_tree . 18 | 19 | $(function(){ $(document).foundation(); }); 20 | -------------------------------------------------------------------------------- /config/locales/simple_form.en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | simple_form: 3 | "yes": 'Yes' 4 | "no": 'No' 5 | required: 6 | text: 'required' 7 | mark: '*' 8 | # You can uncomment the line below if you need to overwrite the whole required html. 9 | # When using html, text and mark won't be used. 10 | # html: '*' 11 | error_notification: 12 | default_message: "Please review the problems below:" 13 | # Labels and hints examples 14 | # labels: 15 | # defaults: 16 | # password: 'Password' 17 | # user: 18 | # new: 19 | # email: 'E-mail to sign in.' 20 | # edit: 21 | # email: 'E-mail.' 22 | # hints: 23 | # defaults: 24 | # username: 'User name to sign in.' 25 | # password: 'No special characters, please.' 26 | 27 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(:default, Rails.env) 8 | 9 | module Bitroad 10 | class Application < Rails::Application 11 | # Settings in config/environments/* take precedence over those specified here. 12 | # Application configuration should go into files in config/initializers 13 | # -- all .rb files in that directory are automatically loaded. 14 | 15 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 16 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 17 | # config.time_zone = 'Central Time (US & Canada)' 18 | 19 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 20 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 21 | # config.i18n.default_locale = :de 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /config/initializers/simple_form_foundation.rb: -------------------------------------------------------------------------------- 1 | # Use this setup block to configure all options available in SimpleForm. 2 | SimpleForm.setup do |config| 3 | config.wrappers :foundation, class: :input, hint_class: :field_with_hint, error_class: :error do |b| 4 | b.use :html5 5 | b.use :placeholder 6 | b.optional :maxlength 7 | b.optional :pattern 8 | b.optional :min_max 9 | b.optional :readonly 10 | b.use :label_input 11 | b.use :error, wrap_with: { tag: :small } 12 | 13 | # Uncomment the following line to enable hints. The line is commented out by default since Foundation 14 | # does't provide styles for hints. You will need to provide your own CSS styles for hints. 15 | b.use :hint, wrap_with: { tag: :span, class: :hint } 16 | end 17 | 18 | # CSS class for buttons 19 | config.button_class = 'button' 20 | 21 | # CSS class to add for error notification helper. 22 | config.error_notification_class = 'alert-box alert' 23 | 24 | # The default wrapper to be used by the FormBuilder. 25 | config.default_wrapper = :foundation 26 | end 27 | -------------------------------------------------------------------------------- /app/controllers/listings_controller.rb: -------------------------------------------------------------------------------- 1 | require 'bitpay' 2 | 3 | class ListingsController < ApplicationController 4 | def new 5 | @listing = Listing.new 6 | end 7 | 8 | def create 9 | @listing = Listing.new(listing_params) 10 | 11 | if @listing.save 12 | redirect_to @listing 13 | else 14 | render "new" 15 | end 16 | end 17 | 18 | def show 19 | @listing = Listing.find(params[:id]) 20 | end 21 | 22 | def purchase 23 | @listing = Listing.find(params[:id]) 24 | client = BitPay::Client.new Figaro.env.bitpay_key 25 | invoice = @listing.invoices.create(file: @listing.file, session_id: request.session_options[:id]) 26 | bp_invoice = client.post 'invoice', { price: @listing.price, currency: 'BTC', redirectURL: "#{root_url[0..-2]}#{invoice_path(invoice)}" } 27 | if invoice 28 | redirect_to bp_invoice["url"] 29 | else 30 | redirect_to root_path 31 | end 32 | end 33 | 34 | private 35 | 36 | def listing_params 37 | params.require(:listing).permit(:name, :description, :file, :price, :bitcoin_address) 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /app/assets/stylesheets/pages.css.scss: -------------------------------------------------------------------------------- 1 | $include-html-global-classes: false; 2 | @import "foundation/components/global"; 3 | @import "compass/css3/background-size"; 4 | 5 | body, html { 6 | height: 100%; 7 | } 8 | 9 | .off-canvas-wrap { 10 | height: 100%; 11 | } 12 | 13 | .inner-wrap { 14 | height: 100%; 15 | } 16 | 17 | .main-section { 18 | height: 100%; 19 | } 20 | 21 | .homepage-hero { 22 | background-image: image-url("background.jpg"); 23 | @include background-size(cover); 24 | height: 100%; 25 | text-align: left; 26 | position: relative; 27 | padding: 40px 5px 30px; 28 | 29 | h1 { 30 | color: white; 31 | font-weight: 500; 32 | font-size: 20px; 33 | line-height: 100%; 34 | } 35 | 36 | h3 { 37 | color: white; 38 | font-size: 20px 39 | } 40 | 41 | @media #{$medium-up} { 42 | padding: 100px 20px 0 20px; 43 | 44 | h1 { 45 | font-size: 32px; 46 | } 47 | 48 | h3 { 49 | font-size: 24px; 50 | } 51 | } 52 | 53 | @media #{$large-up} { 54 | h1 { 55 | font-size: 54px; 56 | } 57 | 58 | h3 { 59 | font-size: 36px; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Zach Latta 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Bitroad::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports and disable caching. 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send. 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger. 20 | config.active_support.deprecation = :log 21 | 22 | # Raise an error on page load if there are pending migrations 23 | config.active_record.migration_error = :page_load 24 | 25 | # Debug mode disables concatenation and preprocessing of assets. 26 | # This option may cause significant delays in view rendering with a large 27 | # number of complex assets. 28 | config.assets.debug = true 29 | end 30 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |If you are the application owner check the logs for more information.
56 | 57 | 58 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Maybe you tried to change something you didn't have access to.
55 |If you are the application owner check the logs for more information.
57 | 58 | 59 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |You may have mistyped the address or the page may have moved.
55 |If you are the application owner check the logs for more information.
57 | 58 | 59 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Bitroad::Application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure static asset server for tests with Cache-Control for performance. 16 | config.serve_static_assets = true 17 | config.static_cache_control = "public, max-age=3600" 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Print deprecation notices to the stderr. 35 | config.active_support.deprecation = :stderr 36 | end 37 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 4 | gem 'rails', '4.0.0' 5 | 6 | # Use SCSS for stylesheets 7 | gem 'sass-rails', '~> 4.0.0' 8 | 9 | # Use Uglifier as compressor for JavaScript assets 10 | gem 'uglifier', '>= 1.3.0' 11 | 12 | # Use CoffeeScript for .js.coffee assets and views 13 | gem 'coffee-rails', '~> 4.0.0' 14 | 15 | # See https://github.com/sstephenson/execjs#readme for more supported runtimes 16 | # gem 'therubyracer', platforms: :ruby 17 | 18 | # Use jquery as the JavaScript library 19 | gem 'jquery-rails' 20 | 21 | # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 22 | gem 'turbolinks' 23 | 24 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 25 | gem 'jbuilder', '~> 1.2' 26 | 27 | gem 'foundation-rails' 28 | gem 'simple_form' 29 | gem 'paperclip' 30 | gem 'haml-rails' 31 | gem 'bitpay-client', git: "git://github.com/zachlatta/ruby-client" 32 | gem 'bitcoin-ruby' 33 | gem 'compass-rails', git: "git://github.com/Labradorom/compass-rails" 34 | gem 'figaro' 35 | gem 'friendly_id' 36 | gem 'coinbase' 37 | gem 'aws-sdk' 38 | 39 | group :doc do 40 | # bundle exec rake doc:rails generates the API under doc/api. 41 | gem 'sdoc', require: false 42 | end 43 | 44 | group :development do 45 | gem 'sqlite3' 46 | end 47 | 48 | group :production do 49 | gem 'rails_12factor' 50 | gem 'pg' 51 | end 52 | 53 | # Use ActiveModel has_secure_password 54 | # gem 'bcrypt-ruby', '~> 3.0.0' 55 | 56 | # Use unicorn as the app server 57 | # gem 'unicorn' 58 | 59 | # Use Capistrano for deployment 60 | # gem 'capistrano', group: :development 61 | 62 | # Use debugger 63 | # gem 'debugger', group: [:development, :test] 64 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # This file is auto-generated from the current state of the database. Instead 3 | # of editing this file, please use the migrations feature of Active Record to 4 | # incrementally modify your database, and then regenerate this schema definition. 5 | # 6 | # Note that this schema.rb definition is the authoritative source for your 7 | # database schema. If you need to create the application database on another 8 | # system, you should be using db:schema:load, not running all the migrations 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). 11 | # 12 | # It's strongly recommended that you check this file into your version control system. 13 | 14 | ActiveRecord::Schema.define(version: 20131208002027) do 15 | 16 | create_table "friendly_id_slugs", force: true do |t| 17 | t.string "slug", null: false 18 | t.integer "sluggable_id", null: false 19 | t.string "sluggable_type", limit: 50 20 | t.string "scope" 21 | t.datetime "created_at" 22 | end 23 | 24 | add_index "friendly_id_slugs", ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true 25 | add_index "friendly_id_slugs", ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type" 26 | add_index "friendly_id_slugs", ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id" 27 | add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type" 28 | 29 | create_table "invoices", force: true do |t| 30 | t.boolean "completed" 31 | t.integer "listing_id" 32 | t.datetime "created_at" 33 | t.datetime "updated_at" 34 | t.string "file_file_name" 35 | t.string "file_content_type" 36 | t.integer "file_file_size" 37 | t.datetime "file_updated_at" 38 | t.string "slug" 39 | t.string "session_id" 40 | end 41 | 42 | add_index "invoices", ["slug"], name: "index_invoices_on_slug", unique: true 43 | 44 | create_table "listings", force: true do |t| 45 | t.string "name" 46 | t.text "description" 47 | t.decimal "price" 48 | t.string "bitcoin_address" 49 | t.datetime "created_at" 50 | t.datetime "updated_at" 51 | t.string "file_file_name" 52 | t.string "file_content_type" 53 | t.integer "file_file_size" 54 | t.datetime "file_updated_at" 55 | end 56 | 57 | end 58 | -------------------------------------------------------------------------------- /config/initializers/friendly_id.rb: -------------------------------------------------------------------------------- 1 | # FriendlyId Global Configuration 2 | # 3 | # Use this to set up shared configuration options for your entire application. 4 | # Any of the configuration options shown here can also be applied to single 5 | # models by passing arguments to the `friendly_id` class method or defining 6 | # methods in your model. 7 | # 8 | # To learn more, check out the guide: 9 | # 10 | # http://norman.github.io/friendly_id/file.Guide.html 11 | 12 | FriendlyId.defaults do |config| 13 | # ## Reserved Words 14 | # 15 | # Some words could conflict with Rails's routes when used as slugs, or are 16 | # undesirable to allow as slugs. Edit this list as needed for your app. 17 | config.use :reserved 18 | 19 | config.reserved_words = %w(new edit index session login logout users admin 20 | stylesheets assets javascripts images) 21 | 22 | # ## Friendly Finders 23 | # 24 | # Uncomment this to use friendly finders in all models. By default, if 25 | # you wish to find a record by its friendly id, you must do: 26 | # 27 | # MyModel.friendly.find('foo') 28 | # 29 | # If you uncomment this, you can do: 30 | # 31 | # MyModel.find('foo') 32 | # 33 | # This is significantly more convenient but may not be appropriate for 34 | # all applications, so you must explicity opt-in to this behavior. You can 35 | # always also configure it on a per-model basis if you prefer. 36 | # 37 | # Something else to consider is that using the :finders addon boosts 38 | # performance because it will avoid Rails-internal code that makes runtime 39 | # calls to `Module.extend`. 40 | # 41 | # config.use :finders 42 | # 43 | # ## Slugs 44 | # 45 | # Most applications will use the :slugged module everywhere. If you wish 46 | # to do so, uncomment the following line. 47 | # 48 | # config.use :slugged 49 | # 50 | # By default, FriendlyId's :slugged addon expects the slug column to be named 51 | # 'slug', but you can change it if you wish. 52 | # 53 | # config.slug_column = 'slug' 54 | # 55 | # When FriendlyId can not generate a unique ID from your base method, it appends 56 | # a UUID, separated by a single dash. You can configure the character used as the 57 | # separator. If you're upgrading from FriendlyId 4, you may wish to replace this 58 | # with two dashes. 59 | # 60 | # config.sequence_separator = '-' 61 | # 62 | # ## Tips and Tricks 63 | # 64 | # ### Controlling when slugs are generated 65 | # 66 | # As of FriendlyId 5.0, new slugs are generated only when the slug field is 67 | # nil, but you if you're using a column as your base method can change this 68 | # behavior by overriding the `should_generate_new_friendly_id` method that 69 | # FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave 70 | # more like 4.0. 71 | # 72 | # config.use Module.new { 73 | # def should_generate_new_friendly_id? 74 | # slug.blank? ||