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
user.phone_1 = '963112233' | |
user.phone_4 = '666111000' | |
user.phone_2 = '678111000' | |
phones = (1..4).map do |i| | |
user.send("phone_#{i}") | |
end | |
=> ['963112233', '678111000', nil, '666111000'] |
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
{ | |
nil => "No se encuentra", | |
'A' => "Opción A", | |
'X' => AMOUNT * RATE | |
} | |
ORDER_TO_BD = { | |
'cheap' => 'price', | |
'expensive' => 'price DESC', | |
'popular' => 'likes_count DESC' |
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
validates :name, presence: true | |
def my_method | |
item.method | |
if subscriber&.valid? | |
workdays = %w(lun mar mie jue vie) |
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
validates(:name, { presence: true }) | |
def my_method() | |
item.method() | |
if subscriber && subscriber.valid? | |
workdays = ["lun", "mar", "mie", "jue", "vie"] |
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
for i in 0..(subscribers.length - 1) | |
subscribers[i].notify | |
end | |
for suscriber in subscribers | |
subscriber.notify | |
end | |
suscribers.each do |subscriber| | |
subscriber.notify |
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 Prestamo < ActiveRecord::Base | |
enum finalidad: { | |
reunificar: 'Reunificar deudas', | |
estudios: 'Estudios', | |
imprevistos: 'Imprevistos', | |
compra_vehiculo: 'Compra de vehículo', | |
viaje: 'Viaje', | |
reformas: 'Reformas hogar', | |
otros: 'Otros' | |
} |
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
Prestamo.estudios.count | |
@prestamo.estudios! | |
@prestamo.estudios? |
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
Prestamo.where(finalidad: 'Estudios').count | |
@prestamo.update_attribute(:finalidad, 'Estudios') | |
@prestamo.finalidad == 'Estudios' |
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 AddFinalidadToPrestamos < ActiveRecord::Migration | |
def change | |
add_column :prestamos, :finalidad, :finalidad_prestamo | |
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
class CreatePrestamos < ActiveRecord::Migration | |
def change | |
create_table :prestamos do |t| | |
... | |
t.column :finalidad, :finalidad_prestamo | |
... | |
end | |
end | |
end |
NewerOlder