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
index: function (req,res) { | |
api_url = api_base_url + '/sandwiches'; | |
request.get(api_url, function(error, response, body){ | |
if (!error && response.statusCode == 200) { | |
var sandwiches = body; | |
console.log(sandwiches); | |
res.view(sandwiches); |
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
var totalPages = 50, buttons = 3; | |
var currentPage = lowerLimit = upperLimit = Math.min(50, totalPages); | |
for (var b = 1; b < buttons && b < totalPages;) { | |
if (lowerLimit > 1 ) { lowerLimit--; b++; } | |
if (b < buttons && upperLimit < totalPages) { upperLimit++; b++; } | |
} |
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
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
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
function createCORSRequest(method, url) | |
{ | |
var xhr = new XMLHttpRequest(); | |
if ("withCredentials" in xhr) | |
{ | |
xhr.open(method, url, true); | |
} | |
else if (typeof XDomainRequest != "undefined") | |
{ | |
xhr = new XDomainRequest(); |
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
@videos = [] | |
@publisher.sources.each { |s| @videos << s.videos.paginate(:per_page => params[:limit] ||= 10, :page => params[:page] ||= 1)} |
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
- Source | |
-- has_many :videos | |
-- belongs_to :publisher | |
- Publisher | |
-- has_many :sources | |
- Video | |
-- has_and_belongs_to_many :tags | |
-- belongs_to source |
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
if Rails.env.production? | |
uri = URI.parse(ENV['REDISTOGO_URL']) | |
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password, :thread_safe => true) | |
Resque.redis = REDIS | |
Resque.after_fork = proc { | |
Resque.redis = Redis::Objects.redis = $redis = REDIS.new( | |
:host => uri.host, | |
:port => uri.port, | |
:password => uri.password, | |
:thread_safe => true |
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
class Property < ActiveRecord::Base | |
acts_as_indexed :fields => [:title, :rate, :location, :max_occupancy, :bedrooms, :bathrooms, :short_description, :about, :directions, :latitude, :longitude] | |
attr_accessor :locale | |
validates :title, :presence => true | |
has_friendly_id :title, :use_slug => true |
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
class TranslateProperties < ActiveRecord::Migration | |
def self.up | |
::Refinery::Properties.reset_column_information | |
unless defined?(::Refinery::Properties::Translation) && ::Refinery::Properties.table_exists? | |
::Refinery::Properties.create_translation_table!({ | |
:title => :string, | |
:location => :string, | |
:short_description => :text, | |
:directions => :text, | |
:amenities => :text, |
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
I have the following line in a Rails mailer: | |
:subject => "Promoción Octubre Mes del Control de la Línea en Figurella!" | |
Notice how the words promocion and linea have accuted letters. I tried using html encoded characters but that didn't solve my problem also the magic string # encoding: utf-8 on top of the mailer class and neither. Any ideas on how can i accomplish this, because the app keeps crashing whenever i try to send an email. | |
Thank You! |