Questions tagged as 'ruby'

1
answer

How to add values to an array of an array in Ruby?

puts "Alunos\n\n" alunos = [["Daniel: ", "Nota: 10\n\n"],["Abima: ", "Nota: 10\n\n"], ["Wilame: ", "Nota: 10\n\n"],["Felipe: ","Nota: 10\n\n"]] puts alunos I wonder if it is possible to add a new student with a new note as a new array in the...
asked by 11.11.2018 / 21:08
1
answer

Erase the last value in an array

I have an array in which each index consists of a letter, which together form a sentence. I was not able to delete the last value of the array in any way. After researching a lot, I managed to delete it, but I'm thinking that the code is very...
asked by 25.04.2015 / 02:50
2
answers

What's the difference between declaring a variable with and without "@" in Ruby?

What's the difference between these two possibilities? //com @ @post = Post.find(params[:id]) //sem @ post = Post.find(params[:id]) Usually in controllers it is used with @ , but in functions each of views is usually used with...
asked by 23.04.2014 / 16:46
2
answers

How to return null if no result found with find_by?

I'm getting a return as array ( [] ) from a scope with find_by and I want the return to be empty ( null ). Here are some snippets of the code: class Dispute::Conference < ApplicationRecord ... belongs_to :dispute,...
asked by 25.01.2017 / 12:03
1
answer

Id of the first table does not load in the DB

I'm trying to create a simple contact directory with two tables: Being one of them empresa :nome and the other contatos :nome :telefone :email ... I created the two tables and placed a Foreign_key in the second one that will receiv...
asked by 08.08.2014 / 20:24
2
answers

Map method does not work as expected

I'm studying Ruby (without Rails, for now). And I have the following scenario: agenda.rb require 'set' class Agenda def initialize @contatos = Set.new end def contatos @contatos.to_a end def query_...
asked by 10.02.2015 / 18:42
3
answers

Why is Vagrant not synchronizing folders?

I'm using: Windows 8 64 bits Vagrant 1.7.2 Virtual box 4.3.28 GitBash 1.9.4 para conexão SSH Box Ubuntu 14.04.02 Trusty 32 bits Box Ubuntu 14.04.02 Trusty 64 bits I'm developing with Ruby on Rails, but I can not edit the generated files...
asked by 13.05.2015 / 21:56
1
answer

Doubt regarding float field query (ruby on rails with mysql)

Hello, I have a question regarding a database with rails. If I declare a field is "float", when I do the query, do I need to use ".to_float" for the rails to understand the type of this field? For example, in this calculation: def se...
asked by 06.10.2016 / 14:36
1
answer

Dynamic calculations in Rails

I hope you can help me. I have a Rated that has reviews , I have several calculations to determine whether or not it will go through a trial step. For example one of these calculations is calcula_pontuacao_minima() #Cálculo defi...
asked by 30.05.2014 / 01:03
2
answers

Ruby Bematech integration (or similar)

Has anyone done any Ruby integration with a Bematech or other printer? What gems or ways can you print to a fiscal printer?     
asked by 30.01.2014 / 05:08