- Add initializer to
config/application.rb
- Add new class to
app/models/spree/calculators/[class_name].rb
- Add logic to class file
Class must have the following methods:
def self.description
"Custom FlexiRate"
end
# put in config/application.rb | |
config.to_prepare do | |
::PagesController.module_eval do | |
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? } | |
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? } | |
end | |
::Page.module_eval do | |
after_save :clear_static_caching! | |
after_destroy :clear_static_caching! |
_complete_ssh_hosts () | |
{ | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \ | |
cut -f 1 -d ' ' | \ | |
sed -e s/,.*//g | \ | |
grep -v ^# | \ | |
uniq | \ | |
grep -v "\[" ; |
class Api::RegistrationsController < Api::BaseController | |
respond_to :json | |
def create | |
user = User.new(params[:user]) | |
if user.save | |
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
return | |
else |
1xx Informational | |
100 Continue :continue | |
101 Switching Protocols :switching_protocols | |
102 Processing :processing | |
2xx Success | |
200 OK :ok |
class AddDeviseColumnsToUser < ActiveRecord::Migration | |
def self.up | |
change_table :users do |t| | |
t.string :authentication_token | |
end | |
end | |
def self.down | |
change_table :users do |t| | |
t.remove :authentication_token | |
end |
config/application.rb
app/models/spree/calculators/[class_name].rb
Class must have the following methods:
def self.description
"Custom FlexiRate"
end
<!-- | |
Inspired on Dr.Nic ruby-tmbundle (https://github.com/drnic/ruby-tmbundle/blob/master/Snippets/Insert%20ERb's%20%3C%25%20__%20%25%3E%20or%20%3C%25%3D%20__%20%25%3E.tmSnippet) | |
In your Sublime Text 2 User folder (Sublime Text 2/Packages/User), create this file and give a name "erb.sublime-snippet". | |
Than open a Ruby on Rails view file like HAML or ERB, type "erb" command and tab key. | |
This create ERB tag on your view file. | |
--> | |
<snippet> | |
<content><![CDATA[<%= ${0} %>]]></content> | |
<tabTrigger>erb</tabTrigger> |