Skip to content

Instantly share code, notes, and snippets.

View ysinc88's full-sized avatar

yair segal ysinc88

  • LED Yair
  • Israel
View GitHub Profile
@ysinc88
ysinc88 / pages_controller.rb
Created February 26, 2015 20:23
Product images per product
class PagesController < ApplicationController
def store
@products = Product.all
render 'store'
end
end
@ysinc88
ysinc88 / mini-gallery.html.erb
Last active August 29, 2015 14:16
Change target div SRC with @this src
@ysinc88
ysinc88 / SimplyLightBox.js
Created March 2, 2015 20:00
simple lightbox
// SimplyLightBox.js is provided "AS IS" WITHOUT WARRANTY OF ANY KIND
jQuery(document).ready(function($) {
var current, size;
$('.lightboxX35').click(function(e) {
e.preventDefault(); // prevent default click event
var image_href = $(this).attr("href"); // grab href from clicked element
@ysinc88
ysinc88 / product.rb
Last active August 29, 2015 14:16
Simple show not working
class Product < ActiveRecord::Base
belongs_to :product_category
has_many :product_images
has_many :led_configurations
has_many :leds, through: :led_configurations
include FriendlyId
friendly_id :name, :use => [:slugged]
@ysinc88
ysinc88 / controller.rb
Created March 12, 2015 17:23
LED's associations
#How should one chain them ? Product > led_config > led
@products = Product.all
@ledconfig = LedConfiguration.all
@leds = Led.all
@ysinc88
ysinc88 / loop.html.erb
Last active August 29, 2015 14:17
sum return values from loop
<% p.led_configurations.map(&:quantity).inject(:+) do |c| %>
<%= c.quantity %>
<% end %>
# outputs 200 300
@ysinc88
ysinc88 / development.rb
Last active August 29, 2015 14:18
Locales
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks); I18n.fallbacks[:fe] = [:en]
@ysinc88
ysinc88 / controller.rb
Created April 4, 2015 11:59
each loop from 2 models
class PagesController < ApplicationController
def store
@products = Product.all
end
end
<% @sections.each do |s| %>
<tr>
<td><%= s.header %></td>
<td><%= truncate(sanitize(s.content), length: 80) %>
</td>
<td><%= link_to "edit", edit_admin_section_path(s) %></td>
</tr>
<% end %>
@ysinc88
ysinc88 / welcome.html.erb
Created May 24, 2015 14:32
Execute bash script
<h1><%= @download %></h1>
<%= link_to "download", download_path(:ydit => "SB8-YY2DyHI") %>
<ul>
<% @mp3s.each do |m| %>
<li><%= m %></li>
<% end %>
</ul>