Skip to content

Instantly share code, notes, and snippets.

@citrus
citrus / blog.rb
Created June 17, 2014 04:51
Ruby wordpress API connector - For use with WP-API
require 'uri'
require 'net/http'
class Blog
class Connection
def request(url, &block)
req = Net::HTTP::Get.new(url)
req.basic_auth(ENV['blog_user'], ENV['blog_password']) if ENV['blog_user']
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define('progressbar', [], function() {
return factory();
});
} else {
// Browser globals
root.ProgressBar = factory();
}
NameError in Admin/products#index
Showing /usr/local/lib/ruby/gems/1.9.1/gems/spree_core-0.40.2/app/views/admin/products/index.html.erb where line #37 raised:
undefined local variable or method `to_ary' for #<Product:0x0000010551d460>
Extracted source (around line #37):
34: <% end %>
35: <td class="actions">
36: <%= hook :admin_products_index_row_actions, locals do %>
@citrus
citrus / Dev Engine
Created March 11, 2011 08:04
A rails engine that reloads the lib/dev folder on each development request. Useful for developing gems.
module DevEngine
class Engine < Rails::Engine
def self.activate
Dir.glob(File.join(File.dirname(__FILE__), "dev/**/*.rb")) do |c|
print "loading #{c}... "
Rails.env.production? ? require(c) : load(c)
puts "done."
end
@citrus
citrus / spree_how_to.md
Created April 28, 2011 16:42
Creating a Spree Site...

Creating a Spree Site

Here's how to get up and running on version 0.70.x of Spree Commerce... For previous versions please refer to these instructions.

We'll be using Bundler and Rails 3.1, so make sure you've got those installed before moving on...

First create a new rails project:

rails new my_spree_site

@citrus
citrus / gist:953865
Created May 3, 2011 18:08
wtf routes
# routes.rb
Rails.application.routes.draw do
scope(:module => "News") do
constraints(
:year => /\d{4}/,
:month => /\d{1,2}/,
:day => /\d{1,2}/
) do
@citrus
citrus / gist:963163
Created May 9, 2011 19:10
Rubygems 1.8 complains!
Spencer@mbpro $ rails s
NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed on or after 2011-10-01.
Gem::Specification#has_rdoc= called from /usr/local/lib/ruby/gems/1.9.1/specifications/actionmailer-3.1.0.beta1.gemspec:19.
NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed on or after 2011-10-01.
Gem::Specification#has_rdoc= called from /usr/local/lib/ruby/gems/1.9.1/specifications/actionpack-3.1.0.beta1.gemspec:19.
NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed on or after 2011-10-01.
Gem::Specification#has_rdoc= called from /usr/local/lib/ruby/gems/1.9.1/specifications/activemodel-3.1.0.beta1.gemspec:18.
NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed on or after 2011-10-01.
Gem::Specification#has_rdoc= called from /usr/local/lib/ruby/gems/1.9.1/specifications/activerecord-3.1.0.beta1.gemspec:21.
NOTE: Gem::Specification#has_rdoc= is deprecated with n
@citrus
citrus / Rakefile
Created May 10, 2011 10:37
A Rails App Generator for testing Spree Extensions
# append to Rakefile
desc "preps the testing environment"
task :test_prep do
require 'generators/dummy_generator'
DummyGenerator.new.run!
end
1) Error:
test: Blog::PostsController should get the blog index. (Blog::PostsControllerTest):
ActionController::RoutingError: No route matches {:controller=>"blog/posts"}
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:424:in `raise_routing_error'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:406:in `rescue in generate'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:395:in `generate'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:453:in `generate'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:449:in `generate_extras'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.5/lib/action_dispatch/routing/route_set.rb:445:in `extra_keys'
/Users/Spencer/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.
@citrus
citrus / integration_case.rb
Created June 8, 2011 18:06
Capybara Integration Case
class ActiveSupport::IntegrationCase < ActiveSupport::TestCase
include Capybara
include Rails.application.routes.url_helpers
self.use_transactional_fixtures = false
# Checks for missing translations after each test
teardown do
unless source.blank?