Questions tagged as 'ruby'

1
answer

Find random objects using conditions

I want to search for example 10 random people of the same party I did the following, but this is selecting people from all parties, what can be done? = D class Pessoa < ActiveRecord::Base class << self def filtra_pessoas(...
asked by 28.09.2016 / 07:17
1
answer

Why use nested classes in Ruby?

I see things like: class Teste class Foo end class Bar end end Use classes within classes ... Can anyone tell me why? Is not it better and more correct to use modules? module Teste class Foo end class Bar...
asked by 05.12.2014 / 12:06
1
answer

What does a join table mean?

I was reading the book Beginning Rails 4, when I came across messe excerpt on page 100.    Let's get back to the relationship between users and comments. You need to tell your user that you have many comments through its articles. Basically,...
asked by 04.09.2014 / 14:09
2
answers

Initializing Redmine

I have a small problem initializing my Redmine in the environment. After all the configuration of Mysql etc ... when I use the command to start the application I get the message: ArgumentError (A secret is required to generate an integrity has...
asked by 16.03.2014 / 03:53
1
answer

How to add a link in the Redmine menu only to logged in users?

I've created a link, at the top of Redmine, for a particular industry. I need to know how to hide this link if there is no user logged in. The button was created in the init.rb file of my plugin containing the following syntax ... menu :top...
asked by 14.03.2014 / 15:11
1
answer

Error trying to install SASS / COMPASS

I have a problem installing SASS and COMPASS on my Mac, giving a permission error. I have already freed the read and write files in the finder.    ERROR: While executing gem ... (Errno :: EACCES)       Permission denied - /Library/Ruby/Gems/2...
asked by 03.02.2014 / 21:39
1
answer

Measure time of a routine in Ruby

Is there a function in Ruby to measure the time of a function? In python I use: ini = time.time() #função fim = time.time()     
asked by 27.08.2018 / 06:42
1
answer

Runtime Error in Problem Using Recursion

I'm trying to solve the problem 1030 - Flavious Josephus Legend , from a website of challenges. I send the code and says it has the Runtime error (Accesses an invalid memory or array has little space): vezes = gets.chomp().to_i vezes.times...
asked by 27.08.2018 / 18:57
1
answer

What's the difference between creating a method and a block in a Ruby class?

I have the habit of creating methods this way in Ruby: class MinhaClasse def metodo # meu método end end But sometimes found around the direct creation of a block of code in the class: class MinhaClasse bloco do # meu blo...
asked by 11.06.2014 / 15:58
1
answer

Subtract elements from a two-dimensional array

I have an array x = [[2,5,16,26],[5,28,35,46],[1,9,28,54,60,102],[...]...] Arrays within the array do not have fixed sizes, they can contain 1 to N elements. How do I get a new array y with the subtraction of each element by its pred...
asked by 23.05.2014 / 19:00