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
answer50
viewsHow to search for Entity and Daughters in a single sql
I have 3 classes that relate as follows: class AnamnesisModel < ApplicationRecord has_many :anamnesis_questions accepts_nested_attributes_for :anamnesis_questions end class AnamnesisQuestion <…
-
0
votes1
answer305
viewsQuestions about relationships in Rails "field must exists"
Good morning, I started studying Rails recently and whenever I will define the relationships between the entities in my database arise some doubts. The first time, I created and defined…
-
0
votes1
answer34
viewsNokogiri put tags with separation
teste = Nokogiri::XML::DocumentFragment.parse("") Nokogiri::XML::Builder.with( teste ){ |x| x.exemplo "teste xml" } puts teste.to_xml Message I printed out <exemplo>teste xml</exemplo>…
-
0
votes0
answers57
viewsLoan logic in a library
I’m looking to do a logic of a library book loan, I made a scaffold for book one for user and another for loan. In the list of books in each book has a loaner button when I click it takes the id and…
-
0
votes1
answer54
viewsDirect button depending on whether the user is logged in or not
I have a button that leads to another screen, but if the user is not logged in to the system he should redirect to the login screen and not to the one that is already going. You can do this directly…
-
0
votes1
answer582
viewsCalculation of Ruby Factorial
Create a Ruby script that reads 10 whole numbers and store them in an array. Then the script should calculate the factorial of each of these 10 numbers, and store the results in another array, and…
-
0
votes2
answers50
viewsRuby Application Hosting with Sinatra
I’m starting my Ruby studies with DSL Sinatra. For this I installed Node.js then ruby with Sinatra. My applications locally are working normally. However, I would like to make them available for web…
-
0
votes2
answers44
viewsset shell user to call script in Rails
I need to call a shell script from Rails, with a specific shell user. Example: update_response = `#{deploy_dir}/./update.sh` By default my system is using root user. I would like to know, given this…
-
0
votes1
answer104
viewsMechanize with Nokogiri: trying to get information on Ivs
Hello! I am assembling a Crawler for product information, for this I am using mechanize and consequently Nokogiri, I have a URL (http://www.megamamute.com.br/brother%205652) that returns only one…
-
0
votes1
answer386
viewsGems autocomplete in text editor
Personal is it possible to get an autocomplete experience in some free text editor, similar to what Rubymine does by indexing the Gems code? I tried several alternatives in vscode, like using cTag,…
-
0
votes1
answer357
viewsWhat does arroba (@) mean in variables in Ruby?
What does arroba (@) in front of variables in Ruby? For example @s = gets.to_i
-
0
votes1
answer1601
viewsUndefined local variable or method
class ProdutItem attr_reader :item, :price_unit, :qtde def initialize(item, price_unit, qtde) @item = item @price_unit = price_unit @qtde = qtde end def calc_qtde (price_unit * qtde) end end prod =…
-
0
votes1
answer640
viewsHow to pass parameter for validation/processing in the RUBY view
I’m in deep doubt, I’ll take tips if you see a better option to do what I’m looking for. I have a layout that links to two items in the same view>> <ul class="nav nav-second-level">…
-
0
votes1
answer460
viewsPass parameter of selected line to another RUBY view
I’m a beginner in Ruby. I have a table in a view, that when I click on the line/item it should take the ID of the selected line and pass to the other view that will be triggered, I’m 3 days…
-
0
votes1
answer210
viewsFilter the result of a collection_select based on the selection of another
I need to filter the result of neighborhoods based on the selection of a city. I have a has_many relation through active record. It is possible to perform this filter without Submit? In the models:…
-
0
votes2
answers145
viewsRails 5: Iugu and recurring payment
I looked in the documentation of Yugu which function in Rails I called to create a recurring payment on yugu, but I could not find. Can anyone give me a light on this? There…
-
0
votes1
answer184
viewsHow to Import Classes from Another Package
How do I import a class that is in another package Example: package "model" contains the class "Car", package "execution" contains the class "Main", from within the "Main" I want to import the class…
-
0
votes1
answer184
viewsHow to put a . Gem in Gemfile
Good afternoon, I’m having a problem installing a . Gem through Gemfile. In Gemfile is: gem 'hanaclient', path: '/usr/sap/hdbclient/ruby/hanaclient' Within the /usr/sap/hdbclient/ruby/hanaclient…
-
0
votes1
answer151
viewsShow Logged-in User on rails_admin Dashboard
Good afternoon to everyone, I am developing a project in Rails 5 using Devise, cancancan and rails_admin, what happens is the following, I created some types of users, among them I cite users…
-
0
votes1
answer23
viewsMethod returns me as null
When I create my code below, it returns me this error message, saying that my method is undefined for nil (undefined method 'errors' for nil:NilClass) Code: <ul> <%…
-
0
votes1
answer40
viewsSum error in an array iteration
I started at Ruby the other day and I have a question. I was doing the Hackerrank exercises and in a certain exercise it was necessary to do the sum of the array elements, not simple? Yes. But my…
rubyasked 7 years, 5 months ago Bruno de Sales 346 -
0
votes4
answers261
viewsSequencia Fibonacci
I’m doing a selection process, and they’re asking me to create a Fibonacci sequence, only I don’t know how to create, I even tried (code below) but I didn’t get any results. I have to return element…
-
0
votes1
answer182
viewsIdentify number in array and change to a string
I’m trying to trade divisible numbers for 3 for a word inside my array. I tried to add my if within the array and with no result. def code( n ) if n % 3 == 0 Array.new(n + 1) { |i| i } end…
-
0
votes1
answer55
viewsQueries of records in the bank through date
I’m developing a Ruby sales management system with Rails and the customer needs to consult sales through two calendar dates, which together make up the range of data he wants to be pulled from the…
-
0
votes0
answers171
viewsHow can I make an access control, visually, in ruby on Rails?
I’ve already done the part gráfica(FRONT), however I am having problems in the part of the code. The access control works as follows: if the new group (or profile) is created, I can decide what…
-
0
votes1
answer270
viewsHow to make calculations with elements of a Ruby array?
numeros = [1, 2] class C def calcule_array(*numeros) puts a + b end end numeros = C.new puts numeros I would like to know how to make calculations with whole elements that are inside an array in…
-
0
votes1
answer77
viewsRails and Yugu: Yugu::Subscription.create
I’m trying to sign up a user with the credit card details so I can make subsequent charges to customers. Registration is done on Yugu, but credit card details are not recorded on Yugu. I am using…
-
0
votes1
answer192
viewsHelp with Heroku, don’t show pages with Ruby language?
Hello, I need the help of the noble holders of knowledge. I am studying Ruby on Rails through the Codecademy website. I took some things I learned there, and I tried to put it online on Heroku. It…
-
0
votes0
answers65
viewsError installing package or updating Ruby Gem
Hello! When I apply any control gem install qualqueroutragem or gem update --system this type of error occurs: "ERROR: While executing Gem ... (Argue) Wrong number of Arguments (Given 1, expected 0)…
-
0
votes1
answer84
viewsRuby on Rails Routes
Guys I’m starting at Ruby on Rails and I had a problem with the calls nested Routes: class Maquina < ApplicationRecord has_many :verificacaos accepts_nested_attributes_for :verificacaos end class…
-
0
votes1
answer577
viewsworking with decimal {5,2} Rails
I created my first API in Rails, and I’m using a simple model with to create a basic Crud, I managed to put my application to work I created the cute GET method returned 200, but in my POST is…
-
0
votes2
answers171
viewsRails update to 5.2 error: The direct method can’t be used Inside a Routes Scope block
I am trying to upgrade the Rails version from version 5.1.2 to version 5.2.2 and I am having the following error when I try to climb the application server: The direct method can't be used inside a…
-
0
votes1
answer40
viewsHow to Nest a third nested_form in Rails
I have the following models: Prova, Questao, Alternativa. Being the same with the following associations: Prova has_many :questoes Questao belongs_to :prova Questao has_many :alternativas…
-
0
votes0
answers31
viewsProblems with animation
There is an animation in the game that of the attacking character with the sword, ah sword and an image behind the character, the code draws like this. but my real problem is with Index, when the…
-
0
votes0
answers55
viewsHow to get a variable name?
Is there any way to get the name of a variable using metaprogramming (or reflection, I believe) in Ruby? I want something like nameof of the C#. I was looking for something like: minha_variavel =…
-
0
votes1
answer41
viewsHow to perform a has_many interaction query in Ruby on Rails
I’m having difficulty searching with has_many interactions in ruby on Rails. Goal is to search all vehicles that have no fines type 'guy'... The problem is that the query I made still returns…
-
0
votes3
answers577
viewsError in capturing Cucumber/Capybara test
I need to perform my tests, but there are some errors in the code, but Cucumber is not showing the error, it only brings the error :` incompatible encoding regexp match (Windows-1252 regexp with…
-
0
votes1
answer276
viewsRuby on Rails: Percentage of Total does not work
People need to calculate how many% of the Survivors (endpoint) were abducted and how many were not, but I have no idea how to do but it did not work, I do not know if I declared wrong also in…
-
0
votes1
answer139
viewsError spring - Ruby on Rails 5
I’m following this tutorial Cocoon: Easily create dynamic Forms in Rails on dynamic Forms using Gem Cocoon, but trying to test code running 'Rails' appears several errors related to spring. Has…
-
0
votes1
answer41
viewsMultiple classes for one student
I have a teaching application in it I have a model for Classes (Room) and another for Students (Student). In my business rule, each student can be enrolled in up to three classes. For this I simply…
-
0
votes1
answer31
viewsError comparing Array in IF
This is my code v3 = [] w=j=k=0 puts "Digite o tamanho do vetor 1" m = gets.to_i v1 = Array.new(m) puts "Digite o tamanho do vetor 2" n = gets.to_i v2 = Array.new(m) for i in 0..m-1 puts "Digite os…
rubyasked 6 years, 11 months ago João Gabriel 19 -
0
votes1
answer109
viewsCreating Scaffold Ruby on Rails
Hi I’m new to Ruby on Rails. I’m trying to create a small blog site. I have two tables one for posts and one for comments. Each Post will have many comments, and third table will be the categories…
-
0
votes1
answer150
viewsAction for a borrow button on the Rails
I’m just starting out on ruby on Rails and I’m having a question I need to make a library, I created and I am listing the books, I created a borrow button in each book unit and then this my problem…
-
0
votes1
answer78
viewsGetting nested Sources in the Rails controller
Good evening, this is my first post here, I’m learning to use the tool, sorry if I did something wrong. But here’s the problem... I’m trying to make a clone of "Trello" in Rails for a college…
-
0
votes1
answer25
viewsRor Create and Update
Guys, I’m developing a system in ROR and I have a news table in the bank, and there is a column featured and every time the admin register another news as featured even if there is already one in…
-
0
votes1
answer124
viewsReturn the name instead of the ID in a Rails relationship
I have two related tables in Rails, pessoa and cidade. On the table pessoa have the field cidade_id. How to do, for example, p = Pessoa.find(1) and in place of p.cidade_id already return the name of…
-
0
votes2
answers223
viewsHow to convert an array to hash?
I possess the following return: [{"eh5g4vs84ah84gsdf4a8va"=>"information"}] Is a hash within a array. I’d like to know how I take that Hash from within the array? He’s the return of a…
rubyasked 5 years, 7 months ago Lougans de Matos 391 -
0
votes1
answer315
viewsRuby on Rails search to generate a report
Well I have a project with scaffolds of books and loans and I need to do a search of a specific book and as a result show all the loans that that book had I have no idea how to start doing that.…
-
0
votes1
answer71
viewsMigrations are pending
I’m new to Rails and I’m also learning how to use databases. I’m trying to create a blog that currently has a table that already contains some data. What happens is that I was using the notebook to…
-
0
votes1
answer63
viewsAdding another field to an Httparty field
For example in the "password_confirm" field I want to add the "password field". @@base_url = 'https://api-de-tarefas.herokuapp.com/users' @@body = { "user": { "email": Faker::Internet.email,…