Questions tagged as 'ruby-on-rails'

1
answer

Force SSL in Rails

Let's say you use your browser to interact with the camera on your computer or notebook in some way. This will only happen through an SSL connection, because browsers reject the permission to access the camera if it is not through SSL How do...
asked by 16.09.2016 / 21:23
1
answer

Make searches using repetitions

I created the following method to search random people for a certain party, the problem is that if I want to add another ten people from another party it does not add, it only replaces the search with no party to such party class Pessoa < A...
asked by 02.10.2016 / 16:48
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

Doubt in Creating an app / Server / Notifications

I have a project to develop an Android app, using Phonegap + jQueryMobile, I have already been able to create the interface, change screens and so on. Now comes the hard part for me: the Backend: ( I'll cite what I need to do and if possible,...
asked by 27.04.2015 / 13:47
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
2
answers

How to model with inheritance a structure of People?

Hello, I'm having trouble doing my Person modeling. Theoretically it seems a very simple thing, but I do not find a way that follows, say, "good programming practice". My problem is this: In my system I have a structure of several people, suc...
asked by 07.05.2015 / 15:25
1
answer

Using Single Table Inheritance (STI) in Rails

Assuming a rails project with the Livestock, Agriculture, Fish farming and improvement. Being these inherit the properties of a model called Activity and are considered Activity types. The templates do not accurately inherit specific method...
asked by 05.05.2015 / 18:55
2
answers

Show error in field instead of flash / notice

I have a Rails application with Twitter Bootstrap that, when creating a record and displaying errors, shows the error in a flash / notice as the image: However, I would like errors to appear in the fields, and change the input class to .has-...
asked by 11.09.2014 / 22:05
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