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
<div id="fbook"> | |
<a href="https://www.facebook.com/sharer/sharer.php?u=https://www.intermixonline.com/category/in-the-mix/look+books/holiday+look+book+2013.do" target="_blank"> | |
<img src= "/text/content/HolidayLookBook2013/images/Fb.png"> | |
</a> | |
</div> | |
<div id="twitter"> | |
<a href="https://twitter.com/share?url=http://www.intermixonline.com/category/in-the-mix/look+books/holiday+look+book+2013.do" target="_blank"> | |
<img src="/text/content/HolidayLookBook2013/images/Tw.png" border="0"/> | |
</a> |
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 arrayMultiply arr1, arr2 | |
n =arr1.length | |
#arr1.inject(0) {|c,i| c + arr1[i]*arr2[i]} | |
c = Array.new(n) | |
0.upto(arr1.length-1) do |i| | |
0.upto(arr2.length-1) do |j| | |
0.upto(arr1.length-1) do |k| | |
arr1[i][k] * arr2[k][j] | |
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
# filtering by category | |
def self.filter_category(category) | |
where("categories.category_name != ?",category) | |
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
@carousel_posts = Post.includes(:categories).where('categories.category_name = "Home Carousel"') |
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
class PhotosController < ApplicationController | |
def index | |
redirect_to Instagram.authorize_url(:redirect_uri => CALLBACK_URL) | |
end | |
def callback | |
response = Instagram.get_access_token(params[:code], :redirect_uri => CALLBACK_URL) | |
session[:access_token] = response.access_token | |
redirect_to "/feed" |
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
<%= form_for([:admin,@variant]) do |f| %> | |
<% if @variant.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@variant.errors.count, "error") %> prohibited this attribute from being saved:</h2> | |
<ul> | |
<% @variant.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> | |
</ul> |
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
class ProductsProductCategories < ActiveRecord::Migration | |
def up | |
create_table :products_product_categories, :id => false do |t| | |
t.integer :product_category_id | |
t.integer :product_id | |
end | |
end | |
def down | |
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
class Cart < ActiveRecord::Base | |
has_many :line_items, :dependent => :destroy | |
has_many :orders | |
def total_items | |
line_items.sum(:quantity) | |
end | |
def add_product(product_id) | |
current_item = line_items.find_by_product_id(product_id) |
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
class Cart < ActiveRecord::Base | |
has_many :line_items, :dependent => :destroy | |
def total_items | |
line_items.sum(:quantity) | |
end | |
def add_product(product_id) | |
current_item = line_items.find_by_product_id(product_id) |
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
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
private # this makes the cart method available to controllers and prevents it from being used as an action on the Controller | |
def current_cart | |
Cart.find(params[:cart_id]) | |
rescue ActiveRecord::RecordNotFound | |
cart = Cart.create | |
session[:cart_id] = cart.id |