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
-
1
votes0
answers60
viewsHow to capture full names and numbers with alphanumerics in Ruby from a.txt file
I tried to do something like that , but he only picks up the numbers after / in the case of enrollment and the names he only takes the first name of the person and if there is no accent , and I do…
-
1
votes1
answer2436
viewsUndefined method `+' for nil:Nilclass - Ruby error
I have the following Ruby codes in three different files. Follow them: Rb program. require_relative "product" require_relative "store" cd = Product.new("CD",20.5) pinico = Product.new("Pinico",30.6)…
-
1
votes1
answer54
viewsHow to display to admin the specific data of each user chosen with Rails
In the administrative part I’m doing my Admin can view all Subscriptions performed by users in a table (this part is working perfectly) Code of my admin controller, def index @subs =…
-
1
votes1
answer178
viewsString tools in ruby
Suppose the following string: "acc5???7???7ss?3rr1???5". How to check if the three question marks exist (exactly three) and if they are before or after numbers that add up to more than 10? I thought…
-
1
votes1
answer458
viewsWhat is the equivalent of "from" and "import" (PYTHON) in Ruby?
I would like to call a script through another script. In Python I use the commands "from" and "import", but which command would be equivalent to do this in Ruby?
-
1
votes1
answer42
viewsCan I use activerecord for basic queries? No mapping?
I do automated testing of a large system, need to validate many tables in different databases. I’m thinking of using Active Record, but all the examples I’ve seen in research show that the tables to…
-
1
votes1
answer45
viewsRails 5 belongs_to namespace
I have the following configuration module Account class Permission < ApplicationRecord end end module Account class GroupPermission < ApplicationRecord belongs_to :permission end end Table:…
-
1
votes1
answer56
viewsRails Cancancan - Doubt about table of Roles
Good afternoon, I have the following models: User.Rb class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and…
-
1
votes1
answer26
viewsRuby unit test does not work
I am running a simple unit test and on my machine it does not show whether the test ran successfully or error. My code below should give a flaw. require 'minitest/autorun' class MagicBallTest <…
-
1
votes2
answers52
viewsHow to average the last table in Rails
personal I have the following doubt that my code it increments for whenever it has an evaluation it shows, but, the media always gets after as if it were a note <%…
-
1
votes0
answers86
viewsProblem with the command Rails db:create Undefined Symbol: rb_enc_alias
Whenever I create a project (from scratch) then I give the command db:create Rails to create the database show me this error: LoadError: /var/lib/gems/2.3.0/gems/pg-1.1.0/lib/pg_ext.so: undefined…
-
1
votes0
answers41
viewswicked_pdf trying to use wrong version of Ruby
I’m getting this mistake: Failed to execute: ["/var/www/apps/menucontrol/shared/bundle/ruby/2.3.0/bin/wkhtmltopdf", "-q", "--margin-top", "3", "--margin-bottom", "29", "--margin-left", "10",…
-
1
votes0
answers34
viewsI cannot solve this problem in my test automation
I’ve tried almost everything and still keep making this mistake in my ruby test automation: incompatible encoding regexp match (Windows-1252 regexp with UTF-8 string) (Encoding::Compatibilityerror)…
-
1
votes0
answers89
viewsrake:db setup error (failed to connect to postgresql) in the Ubuntu subsystem for Windows
Hello! I am using the Ubuntu subsystem (18.04) in windows com ruby on Rails (ruby version 2.5.1 and Rails 5.2.2) and with Postgresql in version 10. I surrounded a rake db:setup at the root of my…
-
1
votes1
answer77
viewsAdding a string in Ruby
all right? I’m learning Ruby So I have a Ruby Fundamentals exercise that asks for the following: I have to add the items of a string, the problem is that this string is like this: 7 -3 10 0 -5 I…
rubyasked 3 years, 11 months ago Isabella Santiago 23 -
1
votes1
answer64
viewsRuby Language - Question about methods
I have a question about the Ruby language: class Carro attr_accessor :marca, :modelo, :cor # declaração do método dentro da classe def velocidade_maxima 250 end end carro = Carro.new puts "insira…
-
1
votes3
answers132
viewsRead private method - Ruby
Hello, everybody. class Automovel def self.tipo_cambio puts "Manual" end def acelera verifica_combustivel() # Injetando combustível puts "Acelerando automóvel" freia() end private def…
-
1
votes1
answer23
viewsWhy is cutting an array out of range not returning nil?
The ruby documentation says that when trying to "cut" an array using an invalid index it will return nil, so because I always get a number array in the index after the last valid index? array = [0,…
rubyasked 3 years, 10 months ago Wilton Ribeiro 23 -
1
votes1
answer165
viewsRuby on Rails - Relation pagination with active record and Kaminari
I’m studying Ruby On Rails and as a learning goal I made an API with the basic features of Instagram. I’m having a hard time paging the results of my following list, I also wanted to display only…
-
1
votes1
answer61
viewsHow to save data from a view that is inside a view in Rails
I rendered a view inside another, because my register has 3 tables inside a CRUD. the form is in the view. I rendered the custom_address this way, Note: it will only save the customer’s address.…
-
1
votes0
answers129
viewsElements not loading on the home page [Capybara - Ruby]
Hello! I am performing the automation of testing a site, using Capybara, Ruby and Cucumber, where it has Lazy Loading, for loading all products. Problem flow: Home page -> Scroll to the first…
-
1
votes2
answers1180
viewsNameerror (uninitialized Constant Sistusuario::Empresasistusuario):
Hello, I did a CRUD with scaffold, and now I’m trying to add something else in the methods, I’m beginner in ruby on Rails,when entering Edit mode,presents me the following error and I can not…
-
1
votes0
answers27
viewsHttparty returns 502 but Postman execution works
I do some APIS testing with httparty and use Postman for smoke testing. When I call the same process in my ruby class, using httparty, it gives me 502, if in seconds I run on Postman, it gives me…
-
1
votes1
answer572
viewsWhat’s the difference between "include" and "extend" in Ruby?
I’m studying Ruby, and I’ve come to realize that there are two ways (maybe there are more) of injecting methods into a class. At first I thought they might be the same things, since Ruby is a…
-
1
votes1
answer49
viewsHow do I use the "define_method" correctly in Ruby?
I was researching on the internet how to create methods dynamically in Ruby and in some forums in English, people spoke to use the method define_method, passing a name to the method and a &block…
-
1
votes1
answer57
viewsHow to boot Spotify API on Rails?
Project link on Spotify API Github How to initialize this project in Rails? normal would be "Rails server", however some files are missing from the standard Rails project and are giving error...…
-
1
votes1
answer181
viewsHow to convert a character to its corresponding hexadecimal in the ASCII Ruby table?
I am using Ruby and have the string "AwX" in hexadecimal. I can write to the screen using the following command: puts "\x41\x77\x58" But I want to do the reverse: I have a string "AwX", but I want…
-
1
votes0
answers46
viewsHow to make a Multipart post request with Restclient?
How do I make a Multipart post request with the Restclient library? Basically, I need a) save photos posted via a form in a local directory. b) have access to metadata as file name, size... As my…
-
1
votes1
answer30
viewsRUBY_ON_RAILS - registrations_controller.Rb - I can’t resolve the user registration permission bug!
Method create: def create # super build_resource(sign_up_params) Permission method: def sign_up_params params.require(:usuario).permit(:nome, :email, :password, :password_confirmation,…
-
1
votes1
answer24
viewsI have this error in form_for Undefined method equipment_index_path
I’m trying to make a form_for to register an equipment, but whenever it goes to the view to create the equipment get error. Model of Equipment: class Equipment < ApplicationRecord validates…
-
1
votes0
answers16
viewsError running ruby script with external Appium server
I’m trying to run a very basic script in Ruby. The idea is to simply validate that my appium script runs using an external appium server. The connection to the remote phone is done normally and the…
rubyasked 3 years, 11 months ago Matheus Echenique 11 -
0
votes1
answer41
viewsDeprecation Warning - Compass Unsemantic
I am having a problem regarding the compilation of some SASS + Compass + Unsemantic codes that generates the following warning: DEPRECATION WARNING on line 17 of…
-
0
votes2
answers183
viewsHow to test with Rspec?
Even studying TDD with Rspec I still have difficulties understanding how to perform certain test. How would I perform a test for this method that has a return of articles? OBS: I use Mongodb with…
-
0
votes1
answer135
viewsWhat is the best method in Rails to create a self-reported category?
I would like a hint to create a self-referenced category where it would be possible to add daughter categories of her own and so susceptibly for the purpose of building a tree using the same object.…
-
0
votes2
answers445
viewsHow to query a polymorphic relationship in Rails 3/4?
I have a table jobs and a table activities. A Job can have several Activities. The relationship is polymorphic. Tables: job activities ----------- ------------- id id ... target_id target_type ...…
-
0
votes1
answer134
viewsHow to install Sass Gem on Windows
I wanted to install Sass’s Gem so I could compile it on Windows. I installed the normal Ruby Installer and soon after I went to the Sass documentation of how to run it in Windows using console mode,…
-
0
votes1
answer67
viewsRack - Redmine Plugin Publish Error
I am creating a plugin for Redmine that will act as generator and publisher of projects within a repository, but I am having problems accessing my button Publish project. The function I created to…
-
0
votes1
answer665
viewsRelationship in Rails, how to declare in Active Record?
I have a list of commercial establishments. Users, at first, are not registered in any of them. When he (the user) decides to register, a relationship is created between him and the establishment.…
-
0
votes1
answer65
viewsHow to create Access Rules for a plugin?
I am developing a plugin for REDMINE. I have a menu created using the :top_menu, so it is at the top of REDMINE , with the Administration , etc... However, I want not all users logged in to the…
-
0
votes1
answer83
viewsProblem with Gem "confirmable" module "Developer" in Rubyonrails
I was implementing the Gem Devise in the Rubyonrails and everything was working perfectly. Then I went to add the "confirmable" module. I took the following steps: I added :confirmable in…
-
0
votes3
answers644
viewsManaging Ruby/Rails versions on Windows
I use Windows and have Ruby/Rails installed on my machines using Rails Installer. Currently I have installed Ruby 1.9.3 and Rails 4.0.2. Today I read about the new Rails 4.1 and I thought: If I…
-
0
votes1
answer409
viewsHow to open a form within a modal with Rails 4 and Foundation?
I have a product register in Rails. I am using Zurb-Foundation 5 as a lib in the Front-End. How do I call an inclusion form within a Modal Window in the Foundation. I created a partial with the form…
-
0
votes0
answers24
viewsRelationship N:N on Ruby on Rails
I have 3 tables in my project that need to be related: responsabilities, knowledges and knowledges_responsabilities, which summarizes : Each responsabilitie may have 1 or more Knowledges, and each…
-
0
votes1
answer235
viewslink_to action and id
I want to do an action to change the password and I have the following link_to to redirect to html.erb with the correct user <%= link_to 'Mudar Senha', "edit_password_form/" + @usuario.id.to_s…
-
0
votes2
answers1190
viewsAccess local printer
I have the following problem, I have an application ruby-on-Rails and I need to print labels on a printer that is installed on the client’s computer, as I do to print these labels directly through…
-
0
votes1
answer99
viewsDeploy with Capistrano
I have to run my Rails app on one machine and DBMS (in this case Postgresql) on another server. I set up the database.yml as follows: production: <<: *default database: nomedobanco username:…
-
0
votes1
answer552
viewsCreating a new view in a Controller
In a Rails project, I created a Scaffold Responsability and consequently Rails created the whole basic structure of this Scaffold. I created a has_and_belongs_to_many relationship between a model…
-
0
votes1
answer95
viewsNull values in check boxes
In my application, I need that if the User unchecks all check boxes informed to him , be saved a Array nulo or []. I’m using params[:parametro1][:parametro2_ids] ||= [] after initializing my Action…
-
0
votes2
answers265
viewsHow to automatically initialize has_many attributes in Rails
Currently I have 3 model class Regiao < ActiveRecord::Base has_many :tipofretes has_many :valorfretes, through: :tipofretes end class Tipofrete < ActiveRecord::Base has_many :regiao has_many…
-
0
votes1
answer84
viewsSending Records from a new View
I created a new action knowledges on my controller responsabilities and created a view called nested_knowledges. I made the action , render this view. I put the following code in this view: <%=…