This file contains hidden or 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 File.expand_path('../boot', __FILE__) | |
| require 'rails/all' | |
| # Assets should be precompiled for production (so we don't need the gems loaded then) | |
| Bundler.require(*Rails.groups(assets: %w(development test))) | |
| module Sample | |
| class Application < Rails::Application | |
| # Settings in config/environments/* take precedence over those specified here. |
This file contains hidden or 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
| Sample::Application.configure do | |
| # Settings specified here will take precedence over those in config/application.rb. | |
| # The test environment is used exclusively to run your application's | |
| # test suite. You never need to work with it otherwise. Remember that | |
| # your test database is "scratch space" for the test suite and is wiped | |
| # and recreated between test runs. Don't rely on the data there! | |
| config.cache_classes = true | |
| # Do not eager load code on boot. This avoids loading your whole application |
This file contains hidden or 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
| Sample::Application.configure do | |
| # Settings specified here will take precedence over those in config/application.rb. | |
| # Code is not reloaded between requests. | |
| config.cache_classes = true | |
| # Eager load code on boot. This eager loads most of Rails and | |
| # your application in memory, allowing both thread web servers | |
| # and those relying on copy on write to perform better. | |
| # Rake tasks automatically ignore this option for performance. |
This file contains hidden or 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
| Sample::Application.configure do | |
| # Settings specified here will take precedence over those in config/application.rb. | |
| # In the development environment your application's code is reloaded on | |
| # every request. This slows down response time but is perfect for development | |
| # since you don't have to restart the web server when you make code changes. | |
| config.cache_classes = false | |
| # Do not eager load code on boot. | |
| config.eager_load = false |
This file contains hidden or 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
| <% custom_cache custom_cache_key('product-tile', @product.id), @product.updated_at, dogpile_protection: true do %> | |
| <%= @product.name %> | |
| <% end %> |
This file contains hidden or 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 custom_read_dogpile(name, timestamp, options) | |
| result = Rails.cache.read(timestamp_key(name, timestamp)) | |
| if result.blank? | |
| Rails.cache.write(name + ':refresh-thread', 0, raw: true, unless_exist: true, expires_in: 5.seconds) | |
| if Rails.cache.increment(name + ':refresh-thread') == 1 | |
| result = nil | |
| else | |
| result = Rails.cache.read(name + ':last') | |
| end |
This file contains hidden or 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 custom_write_dogpile(name, timestamp, fragment, options) | |
| Rails.cache.write(timestamp_key(name, timestamp), fragment) | |
| Rails.cache.write(name + ':last', fragment) | |
| Rails.cache.delete(name + ':refresh-thread') | |
| fragment | |
| end |
This file contains hidden or 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 result.blank? | |
| Rails.cache.write(name + ':refresh-thread', 0, raw: true, unless_exist: true, expires_in: 5.seconds) | |
| if Rails.cache.increment(name + ':refresh-thread') == 1 | |
| # we are the first visitor | |
| end | |
| end |
This file contains hidden or 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
| # Model to hold the current state | |
| # position: last scrollTop before clicking an item | |
| # state: Can be ITEM_VIEW or PRODUCT_LIST | |
| # productDetailsHTML: The HTML for the detail view | |
| class window.ProductViewState extends Backbone.Model | |
| @PRODUCT_LIST = 'product_list' | |
| @ITEM_VIEW = 'item_view' | |
| # View to manage transitions between two states | |
| class window.ProductView extends Backbone.View |
This file contains hidden or 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
| <h1><%= @product.name %></h1> | |
| <div> | |
| <img src="<%= @product.image_url%>"/> | |
| </div> |