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
answer55
viewsComparison __FILE__ and $0
I recently saw this decision-making in a ruby code: if __FILE__ == $0 .... So I had it printed out __FILE__ and $0 separately in irb and saw that the two pass the same information, my doubts are:…
-
0
votes1
answer604
viewsUndefined method `id' for nil:Nilclass
I’m a beginner in Ruby, and I made this mistake... def new @section = Section.new({:page_id => @page.id, :name => "Default"}) @pages = @page.subject.pages.sorted @section_count = Section.count…
-
0
votes2
answers78
viewsHow to register a new Person when you create a new Customer
po I am with a question already a while breaking the head, next, I have a model Person, which is the Generica for person and the model Customer, which belongs to Person, so: class Person <…
-
0
votes1
answer624
viewsAim to catch logged in user
Guys I have a simple application using ruby on Rails a Gem Rails admin and Devise to authenticate i have a model called task where every task belongs to a user , so I would like to pick the user who…
-
0
votes1
answer744
viewsSomeone knows how to solve this problem: cannot load such file -- rubygems.Rb (Loaderror)
I already removed ruby and everything and upgraded the system, but this happened after the Jekyll update :1:in require': cannot load such file -- rubygems.rb (LoadError) from…
-
0
votes2
answers356
viewsRead TXT file on Rails
I have an application in Ruby on Rails and I need to read a particular file txt which will be sent by the user. After sending the file, the file data will be displayed to the user so that it…
-
0
votes2
answers14
viewsHow to set values for config’s of my Handler in tests?
My Handler has 4 configuration variables: config :base_url config :details_path config :create_path config :token I know them and my lita_config file, but to test my Handler, I need to set values…
-
0
votes1
answer191
viewsIs Gems Ruby or On Rails?
I’m starting in Ruby and On Rails. I got a little confused about "Gem", it’s part of Ruby or On Rails? Example of command below. gem install nome gema
-
0
votes0
answers138
viewsXfce terminal does not recognize ruby and Rails commands
Hello, when trying to run ruby or Rails commands on the linux terminal Manjaro error occurs stating that the command is not recognized. I tried to perform the same procedure I used for Ubuntu, but…
-
0
votes1
answer236
viewsSave data from a WYSIWYG editor to the database
I will have a "form" inside it will have a WYSIWYG like take the typed data from inside it and save in the database, because I will have text and images inside. I am developing in Ruby, and trying…
-
0
votes1
answer236
viewsHow to use the Gem Materialize Sidenav component
I want to use the Sidenav of Materializecss, but when I put it in application.html.erb, using using the documentation images do not stay in the place they should be. Follow the current code:…
-
0
votes1
answer379
viewsError "bash: ruby: command not found"
I’m trying to install Ruby on Rails on Windows, but I install and whenever I try to use Git BASH in the "Sites" folder that is created in the installation, this error appears. How can I fix? Command…
-
0
votes2
answers468
viewsNameerror in Postscontroller#index | uninitialized Constant Postscontroller::Post
Guys, accidentally my girlfriend went through the folders of my project in Ruby on Rails and started giving this error. What can I do? He doesn’t seem to recognize the Post as a class...…
-
0
votes2
answers147
viewsWhere’s my mistake in this Ruby code?
I’m having trouble in methods with passing parameter, the code runs, but it moves when I pass var within one method and receives as parameter in another. I’m new to Ruby. def player_welcome puts…
-
0
votes1
answer37
viewsRails 4.2.6 error authenticate method
I am trying to use the authenticate method and the Rails returns Nomethoderror: Undefined method `authenticate' for #. My controller: class Sessionscontroller < Applicationcontroller #include…
-
0
votes1
answer88
viewsLogin Help [Ruby On Rails - Gem Devise]
I’m using Gem Devise to create a login system. However, my project requires 2 login verification fields instead of just 1. For example, the company has 5 departments, the user has the 0010 code and…
-
0
votes2
answers187
viewsCounter on model
I’m looking for a way to add an incremented variable to the id of a div, could someone tell me the most recommended way to do this? my difficulty in making this increment is due to the Cocoon that…
-
0
votes2
answers134
viewsError starting HTTP server in Ruby
Hello guys I’m new with Ruby and I’m trying to create my first project but when I will start the server with the command rails server i get this mistake: João@joao-note MINGW64…
-
0
votes1
answer43
viewsRspec test failing because of Databasecleaner
I was having trouble with tests about 4 days ago. At first, I had trouble with "database is locked" and in the file where the DatabaseCleaner is configured; changed two lines they used :transaction…
-
0
votes1
answer42
viewsSpecial character function: '=' in method name
Good afternoon, everyone. I know Ruby accepts three special characters in the method name: '!', '?' and '='. I need to know what "=" indicates and what it does.
-
0
votes1
answer131
viewsError installing Rails on Linux Mint
While running sudo Gem install Rails, I received this error message: Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native…
-
0
votes2
answers335
viewsRails + Materialize Select field
Diplomats, I have the following problem: <div class="input-field"> <%= f.label :kind_id %> <%= collection_select(:contact, :kind_id, @kind_options_for_select, :id, :description,…
-
0
votes1
answer95
viewsHow to mock a nonexistent class with Rspec Mock
I’m creating a lib that will use a model pattern of Rails, only that for the development of this lib I need to test without the presence of this model. So think about mocking (I’m using Gem…
-
0
votes1
answer97
viewsNested Translation wrong Inflection
Opa, The problem is this: I have a model called Idea and I’m trying to add a new nested in it to Ideategoria which is an associative with Idea. So we have: Idea: has_many :ideia_categories,…
-
0
votes1
answer1605
viewsWARNING: You must use ANSICON 1.31 or Higher
I am trying to run my automated tests but this error happens to be related to ANSICON. I tried to perform the installation on my Windows 10, but it does not allow.…
-
0
votes2
answers175
viewsDoubt Gem Devise
Hello, I’m using Gem Aim for a project of my own and a question has arisen, how do I leave only one route free, for example I want all other routes need login and password less the main page. I did…
-
0
votes0
answers201
viewsHow to make a time chronometer from a set date?
I made a small system that records tasks. The user logs in and registers a title with a description and date of type datetime in the database. In the system it can view its tasks, delete and edit. I…
-
0
votes1
answer19
viewsAddition of Array to a Hash during a loop does not persist the data until the end
I had to come to you for help because I cannot see where I am wrong, certainly a nonsense. I am reading a csv and structuring this data into a Hash, where I have a header as key and a array of…
rubyasked 7 years, 8 months ago Luiz Carvalho 3,644 -
0
votes0
answers49
viewsprogramming in Ruby on Rails
I have a form and include a table médicos, and this table has a field enum where you can choose the option of cooperativa, but I have to check on another table of cooperativa if this doctor has a…
-
0
votes0
answers313
viewsRead TXT/DAT file and Parsing before saving to database (mysql)
I have an application in Ruby on Rails whose one of the features is to read a text file with the following extensions "TXT/DAT", for this, I need a simple page (only an input field(file) and a…
-
0
votes2
answers72
viewsQ. Rails Undefined method `full name_for #<Room:0x0000000ed6d478>
My Controller: class RoomsController < ApplicationController before_action :set_room, only: [:show, :edit, :update, :destroy] def nome_completo "#{title}, #{location}" end # GET /rooms # GET…
-
0
votes1
answer89
viewsDeploy a ruby app to Heroku
I’m trying to deploy a ruby app to Heroku. The whole log is at this link. I thought it was the error below (which appears in part of the log), but even after installing Yarn (I included in Gem and…
-
0
votes1
answer211
viewsCalculate the elapsed time after creating a record
I’d like to know how calculate the time between creating a record (created_at) and the current time. My intention is to display this difference in seconds, minutes, hours or days that it occurred.…
-
0
votes1
answer86
viewsbcrypt error in Rails 5.1
In a new project, after installing the Gemfile gems, when I try to start the server with rails s the following error is displayed in the console : LoadError: cannot load such file -- 2.3/bcrypt_ext…
-
0
votes2
answers736
viewsHow to make an HTTP request in Ruby?
How do I request HTTP in Ruby? I need to implement an API, and for that it is necessary to make a REST request for such a URL, as I do a POST for such a request?
-
0
votes1
answer24
viewsNull return of a JS object in Rails
I have the following code: <p id="notice"><%= notice %></p> <h1>Produtos</h1> <table class="table table-hover custom" id="tabelaProduto"> <thead> <tr>…
-
0
votes1
answer61
viewsJS is not being loaded on a RAILS route
Hello! I have the following code snippet from my project’s home page: <li class="next" style="display: inline-block; margin: auto"> <a href="/produtos">→</a> </li>…
-
0
votes1
answer721
viewsAlgorithm to validate CNH
Hello, I need to validate CNH in Ruby, but I can’t find any code and no reference to the validation rule. Does anyone have any of this information? thank you
-
0
votes1
answer141
viewsNomethoderror: Undefined method `Empty? ' for #<URI::HTTPS:0x000000063069d8>
I am making a REST request but while executing I have this error: NoMethodError: undefined method `empty?' for #<URI::HTTPS:0x000000063069d8> My code: require 'net/http' require 'uri' def…
-
0
votes1
answer87
viewsRuby Rails Beginner
How I create a program where I USE my Name and outputs with a greeting?
-
0
votes0
answers71
viewsRails 5.1 simple form
someone help me with the simple form... I’m trying to put a mask on my simple form initially tried as follows :input_html => {:maxlength => 14, :"data-mask" => "999.999.999-99"} didn’t work…
-
0
votes0
answers411
viewsHow to redirect after login - Rails
Routes: Rails.application.routes.draw do get 'home/inicio' root 'login#new' scope "/login" do get "/acesso", to: "login#create" post "/acessorecebendo", to: "login#create" get "/sair",…
-
0
votes1
answer76
viewsMetaprogramming with ruby on Rails in a partial
I am working on a Ruby on Rails project and I am working on a module (Financial) it is linked to several models, and depending on the screen that the user is he can bring a screen with all the…
-
0
votes2
answers123
viewsJquery does not run on the first page load!
Hello, I have a page where the first load of it Jquery is not executed, when updating the page (refresh, F5) the function written in Jquery now works. I’m using Jquery with technology Ruby On Rails.…
-
0
votes0
answers43
viewsString Insert in Ruby for JS
how can I make the code below in Ruby for JS. (3...value_size).step(3) { |num| value.insert(value_size - num, separator) } To step I think of that loop for (var i = 3; i < value_size; i += 3),…
-
0
votes0
answers18
viewsLightbox with admin Rails
Guys, I want to implement a way to "enlarge" the image of the product when it is clickado. I’ve seen some tutorials, Gem’s and nothing works. What I researched would be what jquery Lightbox does.…
-
0
votes1
answer80
viewsGem Wicked_pdf - when breaking page repeats the first row of table
When you have a table and the records do not fit on a single page, on the new page wicked_pdf repeats the first line disturbing the reading of the second page. How do I not display this first line?…
-
0
votes1
answer228
viewsSimple Form different input for a model
I have in my database a column value with Precision 7 and 2 big decimal type. In my form I use the simple form and also use the Mask, ie field for input value would look like this: 70.567,54…
-
0
votes0
answers67
viewsError Bundle install
Every time I turn bundle install this error appears. /usr/local/bin/bundle:23:in `load': cannot load such file -- /usr/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/exe/bundle (LoadError) from…
-
0
votes1
answer138
viewsOperation of the helper collection_select
Good morning, I’m a beginner in Rails and would like to know how the helper collection_select of Rails works, I could not deduce based on explanations and examples in the official documentation.…