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
-
3
votes1
answer58
viewsEnumerable and Ruby Comparable
I read the Ruby documentation about the modules Enumerable and Comparable, but I didn’t really understand what they do. Could someone give me some examples where I use them in my classes?…
rubyasked 6 years, 9 months ago João Pontes 41 -
3
votes1
answer102
viewsHow was ". include?" developed in Ruby?
I was trying to check if a letter is included in an array without using the .include? but I can’t get the same result. Anyone has any idea how .include? from "inside"? The code in question is a kind…
rubyasked 7 years, 2 months ago Vitor Almeida 33 -
3
votes1
answer200
viewsWhat is the real need for the "initialize" method in Ruby?
def initialize(nome = "Anônimo", salario = 0.0) @nome = nome @salario = salario end To clarify, what I can’t understand is the difference between using this method in a class and for what purpose it…
-
3
votes1
answer80
viewsHow can a class also be a method in Ruby?
See the class Integer: Integer.class => Class It also seems that it is a method, at the same time that it is a class: Integer 10.5 => 10 How is this possible in Ruby? Where is this method…
-
3
votes1
answer198
viewsMethod "include?" returning false when there is a character in the Ruby string
I’m a beginner in Ruby and I’m trying to create a Hangman game to test my language skills. In a part of the code, I need to get a letter chosen by the user and check if that letter is present in the…
-
2
votes0
answers174
viewsIs there an MDI form for GTK 3 or 2 in Ruby?
There is a class that defines an MDI form in Ruby GTK 2 or 3, similar to that found in other languages like Delphi, C#, VB etc.? Note: MDI is that form for desktop applications that a window is…
-
2
votes3
answers847
viewsCorrect model test (Rspec)
I created a test to validate my model and I want to know if it is correct. describe Article do it "object article create is valid?" do article = Article.create article.title = "Title for Test"…
-
2
votes1
answer231
viewsError trying to install SASS/COMPASS
I am having a problem installing SASS and COMPASS on my Mac, it is giving an error of permission. I have already released the read and write files in Finder. ERROR: While executing Gem ...…
-
2
votes1
answer297
viewsRegister a Devise "User" through Seeds.Rb
I’m finishing a project and want to create a default user. The entire user registration structure is carried out by the Developer embedded in rails_admin. Through search I found this syntax below…
-
2
votes3
answers128
viewsNomethoderror in Users#show
I’m learning Rails, following a book that has the following code: Usercontroller class UsersController < ApplicationController def new @user = User.new end def edit @user = User.find(params[:id])…
-
2
votes1
answer223
viewsError running continuous integration test - Travis-CI
For learning purposes I am using the services of Travis-CI to carry out the integration tests continues on a personal project. When running the test locally all pass, no errors. However, when…
-
2
votes1
answer1243
viewsHow to route with optional and ordered parameters in Rails 4?
How I make a route like this? site.com/clothing/men/T-Shirts_type/Nike_brand/100-500_price/Red,White,Blue_color/ site.com/clothing/woman/Nike_brand/100-500_price/Red,White,Blue_color/ It should…
-
2
votes1
answer114
viewsHow to add a link in the Redmine menu only for logged in users?
I created a link, at the top of Redmine, for a certain sector of the company. I need to know how to hide this link if there is no logged in user. The button was created in the init.Rb file of my…
-
2
votes2
answers157
viewsInitializing the Redmine
I have a little problem initializing my Redmine in the environment. After all Mysql configuration etc... when I use the command to start the application I get the message: ArgumentError (A secret is…
-
2
votes3
answers579
viewsDelete . bashrc, . bash_profile and . profile files: what are the consequences?
I’ve been trying to install the Ruby and the Ruby on Rails through the RVM but during the installation process I had some problems. I tried to uninstall the RVM through the commands : rvm implode…
-
2
votes2
answers121
viewsRuby and Ruby on Rails version - Openshift
I tried to upload an application made in Ruby 2 and Ror 4 in Openshift and could not. Is an application made in Ruby 2 compatible with Ruby 1.9? What versions are supported by Openshift? Follow the…
-
2
votes1
answer914
viewsButton with a value - Ruby on Rails
I have 2 buttons and each one will have to send a template value and will also be the submit button 1 and button 2 - depending on the button I click it will send the value to the @rating.type field.…
-
2
votes2
answers281
viewsTwo-dimensional array in Ruby
I have the two-dimensional array a = [[1,'a'],[1,'b'],[2,'c'],[2,'d'],[3,'e'],[3,'f'],[4,'g'],[4,'h']] and I want to separate the letters in another array b so that it looks like this: [["a","b"],…
-
2
votes1
answer179
viewsSubtract elements from a two-dimensional array
I have an array x = [[2,5,16,26],[5,28,35,46],[1,9,28,54,60,102],[...]...] Arrays within the array do not have fixed sizes, can contain from 1 to N elements. How do I have a new array y with the…
-
2
votes1
answer760
viewsGoing up Ruby on Rails app in Heroku
I completely followed what was written on that tutorial and I got this mistake: root@neuber-HP-EliteBook-8460p:/home/neuber/node-js-sample/franca# git push heroku master Warning: Permanently added…
-
2
votes2
answers1356
viewsIdentify repeating elements within a two-dimensional array
In an array a = [[1,"José"],[2,"Pedro"],[3,"Maria"],[4,"Lauro"],[2,"Pedro"], [5,"Léo"],[1,"José"],[6,"Caio"]] how to get a new array b that shows the positions of the indices with the repeating…
-
2
votes1
answer119
viewsWhat’s the difference between creating a method and a block in a Ruby class?
I have a habit of creating methods like this in Ruby: class MinhaClasse def metodo # meu método end end But sometimes we find around the direct creation of a code block in the class: class…
rubyasked 10 years, 7 months ago user7261 -
2
votes0
answers88
viewscaches_page in Rails 3 does not work in production
In development the caches_page works normally, but in production, it creates the cache and rewrites the cache at each access. Does anyone have any idea how this problem can be solved? My…
-
2
votes2
answers841
viewsExtra Fields Don’t Save With Devise
I’m new to Rails and I’m trying to implement Devise with a few extra fields. It is saving the email and password correctly, but my fields first_name and last_nameare not being saved. Are nil This is…
-
2
votes2
answers2709
viewsError starting "Rails Server"
Hi I’m trying to install Ruby on Rails on Ubuntu and startar the server using the command rails server returns me the following error. felipe@Dumont:~/mo$ rails server…
-
2
votes1
answer305
viewsSum a value in a field with Rails
Hello! In my users table I have a field of downloads. I would like when the user enters the page I add +1 in this field of the user. What is the best way to do this? Do I really need to make 2…
-
2
votes2
answers172
viewsPull in Heroku database to local
I need to synchronize my database data in production with what is on my site, is there any way to pull the Heroku database to mine on localhost without having to create a new database locally? My…
-
2
votes1
answer334
viewsNomethoderror in Home#index
Next, I received a challenge to create a page with login, using Sign in and with the user logged in, that he could create a task list, an to-do list. The login I managed to do and works well,…
-
2
votes1
answer302
viewsWhat does a "Join table" mean?
I was reading the book Beginning Rails 4, when I came across messe excerpt on page 100. Let’s get back to the Relationship between users and comments. You need to Tell your user model that a user…
-
2
votes1
answer99
viewsProblem with Ruby Gem Chartkick
After the change to daylight time I’m encountering a problem with the Gem Chartkick. I rode my query as follows: Ticket.unscoped.where('created_at >= ? ', Time.now -…
-
2
votes1
answer64
viewsWhy use nested classes in Ruby?
Back and forth I see things like: class Teste class Foo end class Bar end end Using classes within classes... Can anyone tell me what this is for? It’s not better and more correct to use modules?…
-
2
votes2
answers624
viewsInitializing instance variables in Activerecord
I’m having difficulty initializing instance variables in Rails, I need to use a variable in several methods, but this needs to be initialized beforehand, for example: class Test <…
-
2
votes1
answer78
viewsRender a layout across multiple sites
I have the following situation, I have several sites with different layouts and databases, but I wanted them to use the same administrative area, the same Gems, because if I need to fix a bug in the…
-
2
votes2
answers490
viewsAdding more fields to the user table with Gem Devise
I wonder if there is possibility to add more fields to the user table generated by Devise because I need to relate it to others, and add more information. Is there a problem in doing so?
-
2
votes1
answer680
viewsIf/Else in Ruby
I am very beginner in Ruby and while practicing doing some exercises here I came across a mistake that I do not understand yet how it occurs. Well, the error is the following: There is a comparison…
-
2
votes1
answer58
viewsHow to add more lines to a Ruby class?
I began to venture into the world of rubygems. I’m developing a Gem to generate my twitter bootstrap-style app’s Assets, as I intend to reuse my front-end code. All I need to do is put the Assets in…
-
2
votes1
answer397
viewsWhich files should be inserted into . gitignore in a Rails project?
I’m starting in Git and also in Ruby on Rails. I created a new project using rails new myapp -d mysql and added to my Github repository. When creating the project Rails generates multiple files. So…
-
2
votes1
answer210
viewsProblem creating Rails application
Whenever I’m going to create an application, when doing a scaffold (following tutorials) I get the following error: C:\Users\User\Usuarios>rails generate scaffold Usuario nome:string…
-
2
votes1
answer240
viewsHow to run Javascript function on the Current page through the Application Controller?
I’m doing a browser validation (IE < 10) through the Application Controller with the gem "browser". I need any application page that is accessed to run a Javascript function with a message saying…
-
2
votes1
answer347
viewsHow to compare dates that come from a CSV file in Ruby
Good staff I have a CSV file with some data on it in case this: Nome; Data; Salario JOANNA 1981-04-11 7519.07 LUCIMAR 1958-06-10 819.77 PEDRO 1976-05-11 83.43 JOAO 1989-03-12 867.5 CAIO 1954-02-13…
-
2
votes1
answer41
viewsDelete a flash[:Success] a few seconds after being shown to the user?
I have a registration form using Rails, where after the user completes the registration, it is redirected to the login page along with a flash[:success] that shows a welcome message. My doubt is…
-
2
votes0
answers85
viewsSubdomain accessing only specific features with Rails
I’m using Rails 4.2.2 I have the following code in the config/Routes.Rb file: Rails.application.routes.draw do namespace :api, constraints: { subdomain: 'api' }, path: '/' do resources :users end…
-
2
votes1
answer689
viewsQuery using "select" and "joins" with activerecord in Rails 4
I need to make a report and I have the following query: Deducao.joins(:prestador) .select('pessoas.razao_social, pessoas.qtd_min_mensal, count(deducoes.id)') .group('deducoes.prestador_id')…
-
2
votes1
answer381
viewsDoubt about using send() in ruby
The general idea of OO is that each object can react in a different way to the same message. In ruby, I noticed that it is possible to use the send() method and that every Ruby object has this…
-
2
votes3
answers1157
viewsComparing values from an array
I have an array and in this array I have some dates, and I need to print out the dates that are repeated. To obtain this data I created one that goes from the size of the array, and inside this one…
-
2
votes1
answer81
viewsI can’t convert Rails app from sqlite to postgres (to deploy Heroku)
I’ve been trying to convert a rails app in sqlite for postgres in order to use it on Heroku, following this tutorial from Heroku himself: https://devcenter.heroku.com/articles/sqlite3 Only when I’m…
-
2
votes1
answer68
viewsCould not find Gem byebug (> = 0) in Ruby on Rails
When I execute the command rails server, the following message appears to me:: Could not find Gem byebug (> = 0) This is in Windows. I tried using a gem install byebug but it doesn’t work and…
-
2
votes1
answer680
viewsRuby on Rails alphabetical order
I need to alphabetize my category: @posts_categories = Admin::PostCategory.all
-
2
votes2
answers75
viewsWhat is the best way to create a model q has a field that is an integer Enum?
What is the best way to create a model q has a field that is an integer Enum ? ex:Rails g model status ( do not know how to inform that it is an Enum nor the data type)
-
2
votes1
answer884
viewsHow to make a multidimensional matrix read data entered by the user?
F1=[['1','2','3'],['4','5','6'],['7','8','9']] print "\nJogador 1: Escolha uma linha e uma coluna no tabuleiro:\n" L=gets.chomp C=gets.chomp F1[L][C]='X' The idea here is to build an old game.…