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
#/routes.rb | |
get "/productos/:name" => 'products#show', as: :products | |
#/controller.rb | |
def show | |
#buscar producto | |
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
<ul class=” <%= get_price_css(@product) %>”> | |
<li> Nombre: <%=@product.name %></li> | |
<li> Precio: <%=@product.get_price %></li> | |
<li> Fabricante: <%=@product.maker_name || “No disponible” %></li> | |
</ul> |
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
module ProductHelper | |
def get_price_css(product) | |
product.is_in_promotion ? "product-promotion" : "product" | |
end | |
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
# Date | |
# ---------------------------- | |
Date::DATE_FORMATS[:default] = "%d/%m/%Y" # 03-01-2016 | |
#Date::DATE_FORMATS[:default] = "&proc" # November 3rd, 2013 | |
#Date::DATE_FORMATS[:default] = "%B %e, %Y" # November 3, 2013 | |
#Date::DATE_FORMATS[:default] = "%e %b %Y" # 3 Nov 2013 | |
#Date::DATE_FORMATS[:default] = "%Y%m%d" # 20131103 | |
#Date::DATE_FORMATS[:default] = "%e %b" # 3 Nov | |
#Date::DATE_FORMATS[:default] = "" # custom |
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 Setting | |
include Mongoid::Document | |
field :support_email, type: String, default: "" | |
def self.method_missing(method, *agrs, &block) | |
_initialize unless first | |
first.send(method, *agrs, &block) | |
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
def link_tab(content, tab_name, options={}) | |
prefix_active = "active" | |
tab_name = tab_name.to_s | |
css_class = | |
if params[:tab].blank? | |
options[:default] ? prefix_active : nil | |
elsif params[:tab] == tab_name | |
prefix_active | |
end | |
link_to content, current_path({tab: tab_name}), class: css_class |
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
import React, { PropTypes } from 'react' | |
import ReactOnRails from 'react-on-rails' | |
import {Api} from '../../app' | |
export class PaginateMore extends React.Component { | |
constructor(props) { | |
super(props) | |
const current_page = this.props.current_page || 1 | |
this.offset = this.props.offset || 0.8 | |
this.state ={ |
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
window.ClearDOM = { | |
clearOnClick: function(element){ | |
var code_block = $(element).attr('onclick') | |
$(element).on('click', function(event){ | |
eval( code_block ) | |
}) | |
$(element).attr('onclick', '') | |
}, | |
run: function(selector){ | |
$('*[onclick]').toArray().forEach( (element) => ClearDOM.clearOnClick(element) ) |
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 printArguments(target, name, descriptor) { | |
let oldFunction = descriptor.value | |
descriptor.value = function () { | |
console.log(`start ${name} with arguments`, arguments) | |
oldFunction.apply(target, arguments) | |
console.log(`end function ${name}`) | |
} | |
return descriptor |
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 else in jsx | |
//we need to render the tab view if the tab it's active, and loop the users if not users show empty message | |
//option 1 | |
render(){ | |
const {users, tab_active} = this.state | |
return ( | |
<div> | |
{ tab_active == "users" && ( |
OlderNewer