leads_controller.rb
def activate # @leads = Lead.all.where("type = ? AND status = ?", Lead, true).order('id DESC').page(params[:page]) @lead = Lead.find(params[:id]) @lead.status = params[:status] @lead.save! respond_to do |format| format.js end
def minimum_moves(*arrays) | |
return raise 'Length of arrays are not equal' if arrays.first.length != arrays.last.length | |
moves = 0 | |
slice_number = proc { |n| n.to_s.chars.map(&:to_i) } | |
arrays.length.times do |i| | |
first = slice_number.(arrays.first[i]) | |
second = slice_number.(arrays.last[i]) | |
first.map.with_index { |n, i| moves += (first[i] < second[i]) ? (second[i] - first[i]) : (first[i] - second[i]) unless (first[i] == second[i]) && (first.length != second.length) } | |
end |
def sequence_length(array) | |
array.sort { |a, b| a <=> b }.each_cons(2) { |a, b| b - a == 1 ? array : array.delete(b) } | |
"Length on sequence: #{array.length} - #{array.sort}" | |
end | |
p sequence_length([100, 4, 200, 1, 3, 2]) # Length on sequence: 4 - [1, 2, 3, 4] | |
p sequence_length([29, 27, 28, 55, 100, 84]) # Length on sequence: 3 - [27, 28, 29] |
$('a[filter-by="m&m"]').click(function(){ | |
var mix = $('.mix').children('.text-block-8'); | |
mix.each(function(index){ | |
if ($(this).text() === 'M&M') { | |
$(this).parent().show(); | |
} else { | |
$(this).parent().hide(); | |
} | |
}); | |
}); |
window.addEventListener("load", function() { | |
alert('HOLA MUNDO'); | |
}); |
body { | |
background-color: red; | |
display: block; | |
height: 100%; | |
margin: 0 auto; | |
width: 100%; | |
} |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
<title>Page Title</title> | |
</head> | |
<body> | |
<h1>Hello, world!</h1> |
var ffachada = document.querySelector('.ffachada'); // InputFile | |
var idData = document.querySelector('idData).innerHTML; // Crgando ID record del formulario | |
var formElm = document.querySelector('.edit_visitors').getAttribute('action'); | |
var imgBSC; | |
ffachada.addEventListener('change', (e) => { | |
e.preventDefault(); | |
var file = e.target.files[0]; // Tomamos la imagen del InputFile | |
var reader = new FileReader(); // Creamos un objeto FileReader | |
reader.readAsDataURL(file); // Codificador a Base64 |
leads_controller.rb
def activate # @leads = Lead.all.where("type = ? AND status = ?", Lead, true).order('id DESC').page(params[:page]) @lead = Lead.find(params[:id]) @lead.status = params[:status] @lead.save! respond_to do |format| format.js end
[ | |
{ | |
"value": "ACURA", | |
"title": "Acura", | |
"models": [ | |
{ | |
"value": "CL_MODELS", | |
"title": "CL Models (4)" | |
}, | |
{ |
def update
respond_to do |format|
# information. Devise solution: https://github.com/plataformatec/devise/wiki/How-To:-Manage-users-through-a-CRUD-interface
if params[:user][:password].blank?
params[:user].delete(:password)
params[:user].delete(:password_confirmation)
end
if @user.update_attributes(user_params)
format.html { redirect_to dashboard_path, notice: 'The user role was updated' }
else