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 User | |
| has_one :plan | |
| has_many :certificates | |
| def remaining_certificates | |
| plan.available - certificates.current_month.count | |
| 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
| puts "hola mundo".class | |
| puts "hola mundo".upcase | |
| puts "curso: ruby on rails. nivel básico".size | |
| puts 2 + 3 | |
| puts 2.+(3) |
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 self.get_superiors_of(user) | |
| superiors = Array.new | |
| return superiors if user.departament.nil? | |
| case user.is_chief | |
| when true | |
| unless user.departament.parent.nil? | |
| superiors = user.departament.parent.users.chiefs.to_a | |
| end | |
| when false | |
| if user.departament.users.chiefs.to_a.count > 0 |
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
| namespace :maintenance do | |
| namespace :questions do | |
| task :clean_up => :environment do | |
| Question.find_each do |question| | |
| if question.authors.size == 0 | |
| question.picks.destroy_all | |
| question.destroy | |
| end | |
| 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
| def full_name | |
| if self.first_name.nil? || self.last_name.nil? | |
| self.username | |
| else | |
| self.first_name+" "+self.last_name | |
| end | |
| end | |
| def full_name | |
| if first_name && last_name |
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
| x = objeto | |
| metodo_raro(x) | |
| print x.nombre #muestra el nombre del objeto original y no el del nuevo | |
| def metodo_raro(x) | |
| x = nuevo_objeto() | |
| return | |
| 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
| window.pricingFunction = -> | |
| max = Math.max solo.height(), basic.height(), business.height() | |
| $('.solo, .basic, .business').height(max) |
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 RequestsController < ApplicationController | |
| def create | |
| if access_allowed? | |
| set_access_control_headers | |
| head :created | |
| else | |
| head :forbidden | |
| 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
| add_column :users, :title, :string | |
| User.reset_column_information | |
| User.all.each do |user| | |
| user.title = Title.find_by_id(user.title_id).name | |
| user.save! | |
| 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
| datos = [] | |
| for i = 1 to n | |
| datos << {nombre: objeto.nombre, apellido: objeto.apellido} | |
| crear = (datos) -> | |
| dato = datos.pop | |
| if dato |