This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spree install app | |
Accept all: | |
spree install app -A | |
spree install app --auto_accept true | |
Skip the migrations and seed data: | |
spree install app --skip-data-install true | |
Change the version of spree: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
n = 100000000 | |
Benchmark.bm do |benchmark| | |
benchmark.report do | |
n.times { 2 + 2 } # Fastest Addition | |
end | |
benchmark.report do | |
n.times { 2.+ 2 } # Slowest Addition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'highline/import' | |
# see last line where we create an admin if there is none, asking for email and password | |
def prompt_for_admin_password | |
if ENV['ADMIN_PASSWORD'] | |
password = ENV['ADMIN_PASSWORD'].dup | |
say "Admin Password #{password}" | |
else | |
password = ask('Password [spree123]: ') do |q| | |
q.echo = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Alchemy::Admin::BaseController.class_eval do | |
include Spree::Core::ControllerHelpers | |
include Spree::Core::ControllerHelpers::Store | |
helper Spree::Core::Engine.helpers | |
# it appears spree is overriding alchemy's layout when the helper methods are included | |
# in here, we basically "recall" alchemy's original code. | |
layout :set_layout | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%meta{"charset" => "utf-8"} | |
%title | |
= title | |
%meta{"content" => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"} | |
%meta{"content" => "width=device-width, initial-scale=1.0, maximum-scale=1", "name" => "viewport"} | |
= raw meta_data_tags | |
= canonical_tag current_store.url | |
= favicon_link_tag image_path('favicon.ico') | |
= stylesheet_link_tag 'spree/frontend/all', media: 'screen' | |
= csrf_meta_tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::Order.class_eval do | |
def similiar_products(limit) | |
# products -> tax_category -> tax_rates -> adjustments -> orders -> products | |
tax_rates = self.products.map do |product| | |
product.tax_category.tax_rates | |
end.flatten | |
adjustments = tax_rates.map(&:adjustments).flatten | |
orders = adjustments.map(&:order).compact |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First you need the migration. Run: | |
# | |
# $ rails g migration add_subtitle_to_spree_product | |
# | |
# And the code is as so: | |
class AddSubtitleToSpreeProduct < ActiveRecord::Migration | |
def up | |
add_column :spree_products, :subtitle, :string | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13:39:06 web.1 | Started GET "/shop/api/taxons?per_page=50&page=1&q%5Bname_cont%5D=&_=1408394174251" for 127.0.0.1 at 2014-08-18 13:36:36 -0700 | |
13:39:06 web.1 | Processing by Spree::Api::TaxonsController#index as JSON | |
13:39:06 web.1 | Parameters: {"per_page"=>"50", "page"=>"1", "q"=>{"name_cont"=>""}, "_"=>"1408394174251"} | |
13:39:06 web.1 | Alchemy::User Load (0.7ms) SELECT "alchemy_users".* FROM "alchemy_users" WHERE "alchemy_users"."spree_api_key" = '' LIMIT 1 | |
13:39:06 web.1 | Rendered /Users/benmorgan/.rvm/gems/ruby-2.1.2/gems/spree_api-2.3.1/app/views/spree/api/errors/must_specify_api_key.v1.rabl (0.6ms) | |
13:39:06 web.1 | Filter chain halted as :authenticate_user rendered or redirected | |
13:39:06 web.1 | Completed 401 Unauthorized in 973ms (Views: 963.3ms | ActiveRecord: 0.7ms) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def key_for(namespace, *objects) | |
object_collection = [] | |
objects.each do |object| | |
if object.respond_to? :pluck | |
object_ids = object.pluck(:id).join '-' | |
max_updated_at = object.pluck(:updated_at).max.to_s | |
elsif object.respond_to? :id | |
object_ids = object.id | |
max_updated_at = object.respond_to?(:updated) ? object.updated : object.updated_at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
OlderNewer