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
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
describe Model do | |
# Lazily loaded to ensure it's only used when it's needed | |
# Try to avoid @instance_variables if possible. They're slow. | |
let(:factory_instance) { build(:some_factory) } | |
describe 'ActiveRecord validations' do |
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
{ | |
"ensure_newline_at_eof_on_save": true, | |
"file_exclude_patterns": | |
[ | |
".DS_Store", | |
".tags*", | |
"*.pyc", | |
"*.pyo", | |
"*.exe", | |
"*.dll", |
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
// Update subtotal and total amounts on checkout, considering fees | |
GrowDough.Behaviors.UpdateTotal = Essential.Behavior.extend({ | |
init: function() {}, | |
events: { | |
'keyup': 'updateSubtotal' | |
}, | |
updateSubtotal: function(e, force) { | |
// Keys and events on which the behavior has to update totals |
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
<img | |
alt="" | |
class="producto-imagen" | |
src="productos/obtenerimagen/?id=5&useDensity=true&width=640&height=360&tipoEscala=contain" | |
data-bind="ghostTo: agregandoACarrito, ghostToTarget: $('.cartCount'), attr:{width: width, ___height: height}, src:imagenes.representativa && imagenes.representativa() && imagenes.representativa().get && imagenes.representativa().get({width: width, height: height, tipoEscala: 'contain', useDensity: true}) || '/img/px.gif'" | |
width="640" | |
___height="360" | |
> |
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
# app/controllers/sessions_controller.rb | |
class SessionsController < ApplicationController | |
def login | |
if current_user | |
redirect_to root_path | |
return | |
end | |
@redirect_path = { path: "/auth/facebook", message: { notice: "Logged in successfully" } } | |
parse_to_path if params[:to] | |
redirect_to @redirect_path[:path], @redirect_path[:message] |
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
# app/controllers/sessions_controllers.rb | |
def login | |
url = "/auth/facebook" | |
url += "?" + params.try(:to_param) if params | |
session[:from] = params[:to] if params.any? | |
redirect_to url #unless user_signed_in? | |
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
# app/controllers/videos_controller.rb | |
def destroy | |
video = Video.find params[:id] | |
video.destroy if video | |
render :nothing => true | |
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
# config/routes.rb | |
resources :photos, only: [:create] | |
resources :videos, only: [:create] |
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
# app/controllers/photos_controller.rb | |
@file = params[:file] || params[:facebook_image_url] | |
if params[:facebook_image_url] && params[:access_token] | |
@photo.image = open(@file + "?access_token=" + params[:access_token]) | |
else … |
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
OmniAuth.config.on_failure = Proc.new { |env| | |
OmniAuth::FailureEndpoint.new(env).redirect_to_failure | |
} |
NewerOlder