Most voted "ruby" questions
Ruby is a dynamic, interpreted, object-oriented, cross-platform, open-source language created by Yukihiro Matsumoto (Matz) in 1995. The [ruby] tag is for issues related to the Ruby language, including its syntax and its libraries. Specific questions about the Ruby on Rails structure should be marked with [ruby-on-Rails] and not [ruby].
Learn more…679 questions
Sort by count of
-
0
votes1
answer45
viewsHeroku Rails 4 Assets do not load
After I have deployed these files below are not being loaded. This is my directory This is my application.Rb Here as they are being called <%= stylesheet_link_tag "home" %> <%=…
-
0
votes1
answer34
viewsError in Bundle install in Travis
When running Trigger a build on Travis, Travis points to the following error. Ruby version 2.3.3 and Rails version 5.1.7. Follows Travis.yml…
-
0
votes1
answer62
viewsFind out which Encode was used in a form
I’m making a request for the site: http://sistemas.cvm.gov.br/? PAS Before making the request, they make a Match of the filters. For example, when I pass Unfair practices he shrunk to…
-
0
votes1
answer92
viewsWhy doesn’t it work?
.Rb:2:in `read': No such file or directory @rb_sysopen - Gamesettings.json (Errno::ENOENT) I’m trying to play a game on ruby using gosu, and in order to change the name of the game without having to…
-
0
votes2
answers104
viewsModelling Ruby on Rails
Guys I have a question I can’t see what the way to solve. I have to perform a stock program in Ruby on Rails that contain some equipment, which will contain some avergiguações. For example, I will…
-
0
votes2
answers226
viewsRendering a JSON object with the merging of different models
I am developing an API with Rails 5 and have the following models: class cotacao < ApplicationRecord belongs_to :usuario has_many :cotacao_itens, dependent: :destroy accepts_nested_attributes_for…
-
0
votes1
answer40
viewsHelp here with a Ruby exercise
Why even if I type 0 or 2 it doesn’t come out of second while while opt==2 print "Digite o valor a ser depositado: " deposito = gets.chomp.to_f saldo = saldo + deposito print "Pressione 0 para…
rubyasked 5 years, 1 month ago Rebeca Aguirrer 177 -
0
votes1
answer50
views`<=': comparison of Integer with String failed (Argumenterror)
I want to know the age, then I made the following code: nascimento = "12/34/5678" dia = nascimento[0,2] mes = nascimento[3,2] ano = nascimento[6,4] dia.to_i mes.to_i ano.to_i age = 2020 - 2000 #ano…
-
0
votes1
answer78
viewsAccess a hash/list in a class
Hello. I’m an intermediate student in python, and recently I started studying Ruby, but like all new language, there are some small difficulties. My question is: Where is the error in this? I used…
-
0
votes1
answer170
viewsMethod of login in Ruby
I’m trying to log in with Ruby, but is showing the error undefined local variable or method `login' for #<Object:0x00000000059ccea8> (NameError) I rode the class: class Login…
-
0
votes0
answers52
viewsMistakes in Ruby come because?
Goal Add (Uri, url) with port. # Ajuda por carlos-romero # https://stackoverflow.com # Ajuda por mu-is-too-short # https://stackoverflow.com require 'uri' require 'socket' url = 'file://C://' class…
-
0
votes1
answer89
viewsRAILS Seed File Runs but Does Not Save Data in Database
I’m creating a file Seeds for popular my database, this file is responsible for popular Grupos(model :grupo) that wheel without problem and also popular TipoAtividade(model :tipo_atividade), who…
-
0
votes1
answer21
viewsProblem with inheritance and classes in Ruby
I have this code. I cannot print the editor variable in the incrementNameTitle method, it is not being displayed. The result is as follows: Publisher: In Flames - Collins! class Editora…
-
0
votes1
answer199
viewsTreating URL/string in Ruby on Rails
I have to edit an incoming URL, but in some cases the URL may contain an external reference with http and it breaks my system, because it only accepted paths to its own platform. Follow a code…
-
0
votes1
answer125
viewsMake a list without EACH in Rails
I would like to know how to create a product listing. Where I have a part of the system that creates a customer and then I can place an order for that customer. By selecting the customer I can add…
-
0
votes2
answers444
viewswhile true x loop
Developing some scripts in Ruby I come across the following situation: There are indeed several Repetition Structures, but 2 in particular caught my attention. while true and loop do. Both generate…
-
0
votes1
answer18
viewsAssign the return of a method to a variable only if it is not nil
I wonder if there is a more ruby-like way to assign the return of a method to a variable only if it is not nil. An example code of how it would work in, say, an ugly way. def meu_metodo(valor) valor…
rubyasked 4 years, 2 months ago Luiz Carvalho 3,644 -
0
votes1
answer44
viewsWhy isn’t to_s being overwritten?
In Ruby you can override methods, even "default" language classes. I just wanted to know why the code I did below does not overwrite properly. class Oi end class Ola def to_s puts "Olá!" end end oi…
-
0
votes1
answer232
viewsHow to define proxy in Capybara
I need to perform my tests, but my work network uses a proxy. What better way to set this up within my env.Rb Below follows my file configuration code "env.Rb" require "selenium-webdriver" require…
-
0
votes2
answers72
viewsProblems with Rails Installation
Good afternoon. While trying to install Rails and add-ons for your installation, I ran into a problem. I can perform the installation and its complement. I followed this tutorial…
-
0
votes1
answer37
viewsHow to check if all objects are present?
Is there a method in ruby that checks whether all objects are present? It would be something to avoid the following use: if @stretch_source.present? && stretch_target.present? Or would this…
-
0
votes1
answer19
viewsSelect receive custom value in Rails
I own a select in my form: <%= form.select :status, options_for_select([ ["Ativo", 0], ["Inativo", 1] ]), {include_blank: "Selecione ..."}, class: "form-control", required: true %> To include…
-
0
votes1
answer69
viewsServer does not start in ruby
My server does not start in ruby. Could someone help me understand why? $ rails server C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bundler-2.0.2/lib/bundler/resolver.rb:287:in `block in…
-
0
votes1
answer43
viewsGraphiql Loading page
I have Graphql in the dev Local machine along with a Gem Graphiql where I can do my queries, but on the test server I can’t access this page .../graphiql. The white screen is written Loading... and…
-
0
votes1
answer94
viewsIs there any way to Take the full path to import a csv File?
As described in the title of my question, I would like to know if you have any way to get the path to a csv file, in case I need this path to automatically import the file. This is my attempt to do…
-
0
votes1
answer35
viewsHow to order a query using all of her data?
My problem is this, I need to order the jobs of all categories according to what is requested in a checked. is a job search site, I need to sort the older Jobs as soon as the checkbox for false, in…
-
0
votes1
answer250
viewsSort a Ruby Hash Array - no implicit Conversion of Symbol into Integer
My question is about sorting a hash within an array in Ruby. I’m learning to code in Ruby, my first contact with programming, I’m exercising by consuming an api. I managed to get to where I wanted,…
-
0
votes1
answer82
viewsChange json format output in Rails?
I have an API that has the data in the following format: [ { "id": 1, "vehicle": "350", "code": "350", "delivery_date": "2019-07-26T00:00:00.000Z", "created_at": "2019-08-07T17:00:37.000Z",…
-
0
votes1
answer79
viewsView inside View
Hello, I’m picking up a code to continue and would like to troubleshoot a problem. i have a CRUD of clients, and within the views, have the cliente_addressee file... I went to observe and found that…
-
0
votes1
answer149
viewsCapybara does not install in Ruby
I’m new to Ruby and I wanted a help, I was trying to install Capybara with Ruby but I’m not getting it. The mistake is: Gem::Runtimerequirementnotmeterror: Capybara requires Ruby version >=…
-
0
votes1
answer32
viewsMerge different Methods Querys into a single JSON
I’m trying to create a select where returns data in json and then created a method that would be a "database" that is another select bringing a result, as I would to juxtapose all this and bring a…
-
0
votes1
answer17
viewswicked_pdf table without border or border
In the development environment I use Windows. soon make the call in config/initializers/wicked_pdf.rb directly in . exe file thus WickedPdf.config = { exe_path: 'C:/wkhtmltopdf/bin/wkhtmltopdf.exe'…
-
0
votes1
answer60
viewsError "must exist" when creating registration in Rails 5.2
I’m creating a Teacher model that has a contact: ActiveAdmin.register Teacher do permit_params :name, :contact_id form do |f| f.semantic_errors *f.object.errors.keys f.inputs "Details" do f.input…
-
0
votes1
answer92
viewsHow exactly does "private" and "protected" work in Ruby?
I’m studying Ruby and arrived at the access control part. I had studied before access control in Java, then I thought it would be the same, but to my surprise, the statement private and protected…
-
0
votes0
answers32
viewsSession problem between Sidekiq and Devise
For some reason after processing Job on Sidekiq a Session falls. Follow the flow and more detail about the problem. Follow the code of Job: class GenerateProfileJob < ApplicationJob queue_as…
-
0
votes1
answer153
viewsStore data from an array in a variable
I have a CSV file with the information as below: nome;cpf;ano;faculdade; Pedro Sampaio;45896588963;2010;fmu; Yuri Martins;45885485896;2012;uninove; Pablo Vittar;32585296363;2020;unip; I read this…
-
0
votes1
answer50
viewsLocal variable or method not defined
I have a Ruby exercise where I have functions to make a simple guessing game with a whole number. After implementing the function 'pede_um_numero' passing the parameters, you are giving error when…
-
0
votes1
answer32
viewsFunction does not modify variable value
I’m trying to make an App that modifies a DB Redis, but when I send the function connect to a user he should do Conectado = true and UsuarioConectado = UsuarioQueConectou. But when the function…
-
0
votes2
answers36
viewsActioncontroller::Routingerror (No route Matches {:action=>"show", :controller=>"license_report"}):
I am creating a menu to access part of relay of some system features, but when creating the controller of license_report, when I try to access the path "license_report_path" He presents me with this…
-
0
votes1
answer102
viewsHow to import file to Ruby on Rails system without receiving "No sunch file or directory @ rb_sysopen - file.txt
My program reads a file . txt for example, iterates over the internal information and store in the database. But at the time the file is sent he gives an error saying he does not know the file…
-
0
votes1
answer45
viewsValidating Ruby CSV format
I need to validate the format of the CSV file in pure Ruby, the validation is for the header. I created this code, but it is not working. What am I doing wrong? I’m new to Ruby. require 'csv'…
rubyasked 4 years, 5 months ago Emerson Moreira 3 -
0
votes0
answers45
viewsHow to use a Bootstrap modal in the Show view
Good night! I would like a help to put a modal to work in the Show view of my project because I’m breaking my head to make it work, if someone can give an attention I am extremely grateful guys. My…
-
0
votes0
answers31
viewsReturn group of objects by referencing the item in the postgres array field
I need a collection of objects having as reference the items of an array field in postgres, duplicating the person in the relationships she participates in. I am using Rails 6 and created the field…
-
0
votes0
answers13
viewsSmartcsv Key Mapping does not change Hash keys
I have a CSV file that I interpret through Smartcsv. However, I need the keys names of the generated hashes to be changed, for use I am using Smartcsv key_mapping but it is not changing the names. A…
-
0
votes1
answer32
viewsHow to return multiple parameters from a Ruby Api name with Faraday
Hello, I have a question of how to return multiple parameters of an attribute in an api. I’ve tried concatenating using | and %df but could not. It only accepts a name and prints correctly, when I…
-
0
votes0
answers12
viewsSql syntax problem running migrate in ruby on Rails(schema_migrations)
all blz? I have a problem trying to upload an application in Rails, when I run the command bundle exec rake db:migrate it gives me a syntax error when creating the schema_migrations table. Follow…
-
-1
votes1
answer111
viewsProblems with wiselinks and turbolinks
I need that, after clicking a button, a modal appears, inside this modal there is a populated form (or not) with Rails objects. The problem is that I can’t change the Accept header to js so that…
-
-1
votes2
answers178
viewsHow to group dates according to month? Ruby + Mongoid
I own a class that contains events and their start dates. I need to retrieve all records by grouping them together so that the first days are listed each time. Example: 2014-01-01, 2014-02-01,…
-
-1
votes1
answer81
viewsError installing Compass on Mac
I am trying to install Compass on my machine and I am facing the following error. I’m using with command with sudo. Building native extensions. This could take a while... ERROR: Error installing…
-
-1
votes1
answer883
viewsHow to call a method with named parameters using a hash
I wonder if you have how to pass parameters to a parameter method named via hash. It has to pass the parameters that remain for another function as in the following example? params = {key:…