Posts by Sidney • 667 points
33 posts
-
0
votes1
answer23
viewsA: Why is cutting an array out of range not returning nil?
The method you are calling is this array[start, length]. The documentation says: If start == self.size and length >= 0, Returns a new Empty Array. That is, if start is the size of the array and…
-
0
votes1
answer132
viewsA: Undefined method `+' for nil:Nilclass - Ruby on Rails
You have null data in the variable @stat. NilClass does not implement the method +. You probably need to pass a default value if the value is null. For example:…
-
0
votes1
answer45
viewsA: Validating Ruby CSV format
The method open in CSV expects to receive the name of a file as the first parameter, but you are passing the content returned by CSV.read('Relatorio_de_Campanhas.csv'), which is not the file name.…
-
0
votes1
answer21
viewsA: Problem with inheritance and classes in Ruby
As Woss commented in his question, you are making an inheritance, when in fact, what you need here is a composition. You can change the book builder to receive a publisher: class Book # code…
-
1
votes1
answer102
viewsA: How to import file to Ruby on Rails system without receiving "No sunch file or directory @ rb_sysopen - file.txt
Your form must have the attribute enctype defined as multipart/form-data. Since you do not have this attribute, what you are receiving is only the file name, with this attribute you can do:…
-
0
votes1
answer12
viewsA: Ruby Gem carrierwave-ftp in Heroku returns Net error::Ftppermerror (500 I won’t open a Connection to
It seems to me that Heroku does not allow active FTP connections. For your information: Net::Ftppermerror (500 I won’t open a Connection to 10.10... (only to 174.12...) FTP timing out on Heroku…
-
0
votes1
answer57
viewsA: Help with a Ruby on Rails query
In that case you need to make one joins with the table users. Game.joins(:users).where(users: { id: [83, 84] }). Take a look at these sections of the guide on Active Record Query Interface to have a…
-
1
votes1
answer28
viewsA: How to refresh page and leave static selection?
Yes, you can do it using the cookies or localStorage. Here is an example of how it can be done using the localStorage. <!DOCTYPE html> <html lang="en"> <head> <meta…
-
1
votes3
answers817
viewsA: How to simplify the translation call on i18n?
You can put this file: https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/pt-BR.yml in the briefcase config/locales/ Then add this line in the file config/application.rb:…
ruby-on-railsanswered Sidney 667 -
1
votes2
answers335
viewsA: Rails + Materialize Select field
This is the method with the parameters to be passed: collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {}) You’re using it this way:…
-
5
votes3
answers2089
viewsA: Get the site name in the javascript url
Try to use: window.location.hostname You can take a look at the Location object, which it has several attributes that might be interesting for your solution. If the url is in a variable, divide the…
-
0
votes2
answers421
viewsA: How to send form_tag variables to javascript function? Rails
When entering the quantity there are several events that can trigger the calculation, you need to know when you want to calculate. When is it typing? When to click outside the text_field? When to…
-
2
votes2
answers12233
viewsA: How to display/hide fields according to selection?
function exibir_ocultar(){ var valor = $("#tipo_pessoa").val(); if(valor == 'pessoa_fisica'){ $("#cnpj").hide(); $("#razao").hide(); $("#cpf").show(); $("#nome").show(); } else { $("#cnpj").show();…
-
4
votes2
answers2295
viewsA: Good Practices for URI in Restful API
I could use the following approach: get /projetos # Lista de projetos post /projetos # Criar um projeto get /projetos/1 # Buscar o projeto com id 1 put /projetos/1 # Atualizar o projeto com id 1…
-
3
votes4
answers364
viewsA: Different methods of creating an object
Usuario usuario = new Usuario(); You are creating an object Usuario and assigning to a variable. After this line the object is accessible by the reference usuario. new Usuario().listar(); You are…
-
2
votes3
answers3735
viewsA: Generate random number between two numbers with Math.Random
Take a look at: https://stackoverflow.com/questions/363681/generating-random-integers-in-a-specific-range import java.util.concurrent.ThreadLocalRandom; ThreadLocalRandom.current().nextInt(min, max…
-
0
votes3
answers1157
viewsA: Comparing values from an array
require 'set' # transforma em um array de uma dimensão csv_temp = csv.flatten # pega apenas as posições que possuem a data csv_temp = (1..csv_temp.size).step(2).map { |x|…
-
0
votes1
answer89
viewsQ: Web Page Optimization with Java
What should I look for to optimize performance on the front end, to minimize css, js etc. keep the head and change only the body? Using Java and Spring MVC, or with Play and Sparks for example.…
-
0
votes1
answer150
viewsA: How to send object as attribute from another JSP object to a Spring controller?
<select name="secao.atributoDeSecaoQueSeraDefinido"> <option value="politica">Política</option> </select> You can try this way, but as you should already have the registered…
-
1
votes2
answers1330
viewsA: URL Forwarding With Spring MVC
On the return of controller, if everything is already configured correctly - /WEB-INF/views/ prefix and . jsp as suffix - just return "pessoa/criar".
-
2
votes1
answer177
viewsA: I can’t access static content in spring-mvc
Barter .addResourceLocations("(/resources/");, for .addResourceLocations("/resources/");
-
2
votes1
answer1128
viewsA: Why put . jsp file in WEB-INF directory?
9.10 Hiding our pages - https://www.caelum.com.br/apostila-java-web/mvc-model-view-controller/ If the pages are in /webapp, the user will have direct access to them. If they are only static pages, I…
-
0
votes2
answers643
viewsA: How to send an error message to view
If it is just an invalid login message, to display error messages when login fails, I do not set anything in the class, just leave the default, which redirects to the login url? error, then in the…
-
0
votes1
answer65
viewsA: Doubt about Hibernate Criteria
The way I thought to solve it was like this, must have better k Create a table that represents the Manytomany link: @Entity public class OrdemServicoCategoria { @Id @GeneratedValue private Long…
-
0
votes2
answers332
viewsA: JSP to import all acquisitions from a directory
Import all at once I’ve never seen it, but if it’s many Imports, you can isolate them in a file and import. <%@ include file="imports.html" %> <jsp:include page="imports.html" />…
-
0
votes1
answer308
viewsA: Problem inserting object with Manytoone JPA
I think it is not even possible the first option, it would be a lot of gabiarra, only if the object is in the session. But I would do with the second option. You take what the user has selected in…
-
5
votes2
answers9897
views -
1
votes1
answer1131
viewsQ: What’s left to configure with Spring boot?
The settings I use with spring are based on Java class, as in this example https://github.com/matheussilvasantos/autocomplete. If this project used the spring boot, what settings would still be…
-
6
votes1
answer235
viewsQ: Popular via builder with Hibernate
I was reading this article http://blog.caelum.com.br/nao-aprender-oo-getters-e-setters/ and talks about using constructors to popular objects and set aside some setters. How can I use constructors…
-
1
votes2
answers327
viewsA: JPQL hibernate for multiple Ikes
List<Cliente> clientes = sess.createCriteria(Cliente.class) .add( Restrictions.in( "nome", palavras ) ).list() Try to do so. You do a search using the in in place of or, who seeks all the…
-
1
votes2
answers305
viewsA: Error in web system authentication
public Autenticavel autenticar(String usuario, String senha) is returning an interface, tries to change to public Cliente autenticar(String usuario, String senha)
-
3
votes1
answer226
viewsQ: How to implement Service Layer with Spring?
Does anyone know any tutorial, examples... any source to learn how to implement service layer?
-
1
votes1
answer184
viewsQ: Why are tables created in Hibernate deleted after stopping the server?
I run my website and it generates the tables in the database. I can even register in the database by the site and its der a select it shows that it was registered. But if I stop the server, and see…