Questions tagged as 'ruby'

2
answers

FATAL failed to allocate memory

Good afternoon, I'm using the gem rb-libsvm:    link In order to generate a template for tweeting (positive / negative). From a database with 19000 positive tweets and 19000 negative tweets I tried to create the template with this...
asked by 09.07.2015 / 19:15
1
answer

If / else in Ruby

I'm a beginner in Ruby and while doing some exercises here, I came across an error that I did not understand as yet. Well, the error is as follows: It has a comparison of a number entered by the user, that if this number is greater than or eq...
asked by 15.03.2015 / 01:25
1
answer

Why is the translation path not being found?

Assuming my yml file is organized this way: pt-BR: alert_system: schedules: teste: 'ss' every: 'Todo Dia:' each: 'A Cada:' each_day: 'A Cada #{dias} Dias' on: 'Na data:' When calling from within a decorat...
asked by 06.03.2015 / 21:25
1
answer

Add method in ActiveRecord :: Base

I created a method in ActiveRecord :: Base and it uses another method to be defined in the model, I need to validate if the model method is set before executing what I need, but it says is always undefined, what could it be? Ex: ActiveReco...
asked by 09.04.2015 / 16:16
1
answer

How do I send errors and exceptions to the main output?

I'm using Ruby 2.1 32 bit. Interpreting scripts as CGI by Apache 2. Through Local IP. I'm in a process of migrating multiple scripts in PHP to Ruby. During the process of writing code, several times error both in typing and some new concep...
asked by 23.04.2015 / 17:37
2
answers

___ ___ erkimt Improves performance - Ruby on Rails ______ qstntxt ___

I have 3 tables:

[users] 1 ----------- n [evaluations] n --------- 1 [items]

Where evaluation can be positive (valuation: true ) or negative (valuation: false ), I need a method that returns all items that the user liked and did not like ... For this I did the following method in the user model:

%pre%

The same principle was adopted for the method for the dislike method

The idea is to do this with many users, the problem is that it is taking a long time to return the data. Is there any way to improve the performance of this code snippet? Any structure that I can keep on the server, because this query is executed many times more than once per user ...

    
______ azszpr28800 ___

I had the idea of trying to do directly in the bank to simplify the process and modified the function to:

%pre%

I've had an improvement of 0.2 seconds in the average ... I'm putting it as an answer because I do not think it will improve more than that, but if someone wants to prove me to the contrary the answer will be very welcome!     

______ azszpr36666 ___

Would not it be less expensive if you paginated? You can use the library link so it will return the paged items I believe will shorten the search time.

    
___

I have 3 tables: [users] 1 ----------- n [evaluations] n --------- 1 [items] Where evaluation can be positive (valuation: true ) or negative (valuation: false ), I need a method that returns all items that the user liked and did not like...
asked by 13.08.2014 / 02:10
2
answers

NoMethodError: undefined method 'similarity_com' for #Class: 0x007ff55873cad0 - RoR

I'm trying to create an attribute of the class that will be an array of similarity among users. Is there something wrong with this construction? Is there a better way to do it? class Usuario < ActiveRecord::Base require 'matrix' @@similar...
asked by 13.08.2014 / 22:39
1
answer

History of edits of a Ruby on rails template

I would like to know how I can create a history with all edits made to a template, in ruby on rails.     
asked by 25.08.2014 / 20:02
1
answer

Power ball in Ruby

I made the following program: class PowerBall def jogo brancas = Array.new 50.times{brancas << false} brancasSorteadas = Array.new 5.times{brancasSorteadas << 0} for x in brancasSorteadas j = rand(48...
asked by 29.08.2014 / 03:16
2
answers

Validation in the model when doing update_attributes in Rails

I want to know how I would do a validation in my model for when the @ model.update_attributes (params) in my controller is called to return a possible error or false which seems to be the default returned by update_attributes. Following the l...
asked by 28.03.2014 / 21:26