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
-
21
votes4
answers15388
viewsHow to make a table responsive using (Twitter) Bootstrap?
I’m working on a web application using Ruby On Rails 4 and much of the interface consists of tables. I would like you to suggest a way to detect the screen size in use and, based on this, hide…
-
21
votes1
answer4711
viewsHow to program in Portuguese in Ruby on Rails?
I would like to know how to program an application in Ruby on Rails in Portuguese instead of English. There are basically three problems in that: How to change the user interface to Portuguese?…
-
21
votes2
answers15418
viewsDoesn’t Java have multiple inheritance?
I had seen somewhere now I don’t remember, I think it was in a course on object orientation, which Ruby possesses. But in Java I’ve never seen it. Is that why abstract classes are used? Or is this…
-
16
votes2
answers3148
viewsWhy does everyone hate multiple inheritance in C++ and what’s your difference to mixins?
I’ve always heard that multiple inheritance in C++ is chaos. Why? It wouldn’t be technically the same thing as using mixins in languages such as Ruby? And what is this abstract class of Java? It’s a…
-
11
votes2
answers1331
viewsRuby - What’s the difference if you use two dots or quotes in a string?
In Ruby I can write some things in two different ways: I can do this: :algo Or this: 'algo' What is the difference?
-
11
votes2
answers160
viewsEqual sign in Ruby method definition
I have come across the following definitions of methods and I would like to know the difference between the first definition and the second. This first has no equal sign in the definition: def nome…
-
10
votes1
answer165
viewsWhat is the difference between `for x in y` and `Enumerable#each`?
We can iterate an array/list in ruby in two ways: Using the syntax for x in y: > for x in [1,2,3] do > puts x > end 1 2 3 => [1, 2, 3] Using the method .each > [1,2,3].each do |x|…
-
10
votes2
answers808
viewsWhat are the size limits of variables in Ruby?
I would like to know the size limit of variables of the following types: String - How many characters can I have in a single string? Integer and Float - What is the largest and smallest number that…
-
9
votes4
answers1446
viewsLoad file to current directory when running irb
It is possible to call irb by passing a library to be loaded as parameter (required): irb -r date But this does not work if I want to load a file in the directory where the command runs: irb -r…
-
9
votes2
answers531
viewsAssociation with scope in Ruby on Rails
I have a Ruby on Rails application in which I have licenses, items that can be licensed, and a table that lists the two (Which items do you have in the license?). Analogously to items in a shopping…
-
9
votes2
answers647
viewsHow to use Ruby blocks
I’m having a hard time understanding blocks in Ruby. Could someone explain to me why we use it?
-
8
votes4
answers265
viewsHow to set --no-ri --no-rdoc as default when using Gem install?
Always when giving Gem install I have to provide the parameters --no-ri and --no-rdoc, I would like this to be standard for this command! How can I do that?
-
8
votes3
answers21946
viewsHow to exchange the value between two variables without using auxiliary variable?
I learned to code in C, but recently I have studied RUBY. Ruby allows us to exchange the value between two variables easily and without using an auxiliary variable, thus: a, b = b, a Without using…
-
8
votes1
answer373
viewsOffline mode Rails app
In a new endeavor, I need a simple application to stay working if the internet connection is lost. Can someone explain to me how to do this? I had thought to use HTML5’s persistence features in case…
-
8
votes1
answer716
viewsIn Ruby on Rails is the business rule on the model?
In Java the business rule is in controller, but I heard a speaker saying that in Ruby on Rails the business rule is on model. Someone confirms that to me?
-
7
votes2
answers2443
viewsHow to print a web page using the backend Rails?
It would be possible to do this? For example: I point a page to my application, and she keeps a image of the page indicated. A print.
-
7
votes2
answers841
viewsWhat is the practical applicability of the super word in Ruby?
There are several explanations on the Internet about it. But I still can’t understand what the practical applicability of the word is super in ruby. Okay, I know it’s meant to call the method with…
rubyasked 10 years ago Pedro Vinícius 1,870 -
7
votes1
answer6657
viewsWhat is attr_accessor in Ruby?
I’m learning Ruby on Rails and in the content I am studying I could not understand well what is the attr_accessor and how it works.…
-
7
votes2
answers213
viewsHeroku deploy with Bower-Rails
I have the gem 'bower-rails' installed in my application but when deploying I have the following error: I added the gem rails_12factor I’m using the buildpack: heroku buildpacks:set…
-
7
votes3
answers402
viewsSending email via a notification button
I wonder if you have done or have any example that can send the link to the following problem: I have a project that has the Books crud and a User controller with their respective views. I made the…
-
7
votes3
answers845
viewsHow to declare a constant in Ruby?
How to declare a constant in Ruby? In other languages I do something like: const CONSTANTE = 1024 And CONSTANTE cannot be changed at runtime. But I can’t find anything like this in Ruby.…
-
6
votes2
answers967
viewsHow to create a test with Rspec to verify user feedback?
That one describe below is the default that Rspec creates. I have a hard time working with TDD (Test Driven Development) and it is difficult to understand the whole procedure. For example, I need to…
-
6
votes1
answer564
viewsHow does a Dependency Injection Framework work? Are they useful in Ruby?
Java and C# people keep quoting frameworks Injection of Dependencies. I know the pattern of Dependency Injection projects, but never worked with such frameworks. In fact, I have no idea how they…
ruby software-architecture pattern-design dependency-injectionasked 10 years, 1 month ago RubyGuy 63 -
6
votes1
answer102
viewsDoubt Relationship Rails
I’m learning Rails still, and I’m in doubt if I’m doing it right. I have a Table Animal and a table Reproduction, each animal may have one or more reproductions and each reproduction will only have…
-
5
votes2
answers126
viewsRuby application that keeps reloading source files
How can I design my application so that whenever I modify and save a file . Rb the application will behave "the new way"? I am making an application that reads the command, executes, prints the…
-
5
votes2
answers296
viewsWhat’s the difference between downcase and downcase!
I’m starting with Ruby and came across the following code: user_input = gets.chomp user_input.donwcase! My question is why I use the exclamation mark after the downcase.…
rubyasked 10 years, 8 months ago filipelinhares 2,417 -
5
votes1
answer210
viewsUpdate BD table by clicking a <li> element
I’m developing a mobile application using jqMobile and Ruby. How to update a database table by clicking on an item in a list. My list is generated like this: <ul data-role="listview"…
-
5
votes3
answers390
viewsCalculate parent and child totals
Friends have 2 templates. Orders have several Details. I use Cocoon to create forms. The order model has a total that is the sum of the child model totals. What I would like to know is what is the…
-
5
votes1
answer188
viewsDefining a tree structure in ruby on Rails
I’m developing a system in ruby on Rails, and I’m stuck on a question. My question is this, I need to create a tree, and then create my 'no' object and I would like it to have a 'no' parent and a…
-
5
votes1
answer296
viewsWhat are the main differences between Ruby and Crystal?
I saw some information about the Crystal language a few days ago, but I would like to understand a little better what the main differences with Ruby. Examples: Which is faster and lighter in…
-
5
votes1
answer85
viewsWhat is the Java equivalent of this Ruby lambda?
In his text on Inversion of Control, Fowler uses as an example an excerpt of code in Ruby that promotes the said principle to "invoke a bind method over the text input field that passes an event…
-
5
votes1
answer109
viewsWhat does << in Ruby mean?
I’m studying a book of programming logic and wanted to know what it means << see what the book is applying to: This balcony to maintain a help variable with the actual size used an array is…
-
4
votes2
answers546
viewsRuby Bematech integration (or similar)
Has anyone ever done a Ruby integration with a Bematech printer or other such ? What Gems or ways to print on a tax printer ?
-
4
votes1
answer816
viewsHow to update with AJAX a list after the action of a remote form?
I have a problem I’ve never had in Java but I’m almost going crazy in Rails. I’m developing a project where there are users and groups. So I created a separate model for relationship N:N between…
-
4
votes3
answers131
viewsProblems with belongs_to when using Ajax in Rails 4
I have three models in my application, Order, Product and Items. Within Items I have the following code: class Item < ActiveRecord::Base belongs_to :product belongs_to :order end I have a form…
-
4
votes0
answers931
viewsHow to make multiple image uploads with Rails 3?
I ran a scaffold with the name "Property", I need to add images next to it preferably in a different model referencing (1 Property can have many images), where the user can select more than one…
-
4
votes2
answers195
viewsCarrierwave - destroy object only after it has been deleted from my storage
Carrierwave only deletes the 'mounted' file after the object in the database has been removed: after_commit :remove_avatar! :on => :destroy https://github.com/carrierwaveuploader/carrierwave I am…
-
4
votes1
answer640
viewsPassing parameters to the as_json method
I am trying to pass parameters to the as_json method (overwriting the method) in my model. Because only with the date that comes from the user can I return my result. According to this past date I…
-
4
votes2
answers255
viewsHow is it different to declare a variable with and without "@" in Ruby?
What is the difference between these two possibilities? //com @ @post = Post.find(params[:id]) //sem @ post = Post.find(params[:id]) Normally in controllers is used with @, but in office each views…
-
4
votes1
answer210
viewsRuby on Rails boot time
In Ruby on Rails, using the Minitest library, the test run time is fast. But the boot time before each rake test (...) is pretty annoying. Is there any way to make it faster? Updating I tried to…
-
4
votes1
answer790
viewsDynamic calculations in Rails
I hope you can help me. I have a Rated who owns evaluations, have several calculations to determine whether or not it will pass an evaluation step. For example one of these calculations is…
-
4
votes1
answer86
viewsFirst table id does not click on BD
I’m trying to create a simple contact schedule with two tables: Being one of them empresa :nome and the other contatos :nome :telefone :email... I created the two tables and put a Foreign_key in the…
-
4
votes1
answer201
viewsProblems running only one unit test on Rails 4
When I run all the tests or just tests a file is working normally, but when I try to run just one test, it just doesn’t run. I have this test require 'test_helper' class UserTest <…
-
4
votes2
answers150
viewsMap method does not work as expected
I’m studying Ruby (no Rails, for now). And I’m on the following scenario: agenda.Rb require 'set' class Agenda def initialize @contatos = Set.new end def contatos @contatos.to_a end def…
-
4
votes1
answer610
viewsDelete the last value in an array
I have an array in which each index contains a letter, which together form a sentence. I was unable to delete the last array value. After searching a lot, I was able to delete, but I think the code…
rubyasked 9 years, 8 months ago Rafael Almeida 2,585 -
4
votes3
answers1108
viewsWhy isn’t Vagrant synchronizing the folders?
I’m using: Windows 8 64 bits Vagrant 1.7.2 Virtual box 4.3.28 GitBash 1.9.4 para conexão SSH Box Ubuntu 14.04.02 Trusty 32 bits Box Ubuntu 14.04.02 Trusty 64 bits I am developing with Ruby on Rails,…
-
4
votes3
answers2889
viewsRunning my Angularjs application on some server
I have a front-end application consuming an Rails api, but I’m new to this idea of separating the front-end from the back-end, my api runs on localhost:3000, and my front is simply a folder that I…
-
4
votes1
answer112
viewsYour Ruby version is 2.0.0, but your Gemfile specified 2.2.2
I can’t spin the bundle install in my project, when I spin it appears Your Ruby version is 2.0.0, but your Gemfile specified 2.2.2. But I’ve already made one rbenv local 2.2.2and when I spin the…
rubyasked 8 years, 11 months ago user27585 -
4
votes2
answers231
viewsQuick search for a string or part of it in an Array
I have the following array: images = %W( droido 7midias vigilantes sebrae_mei dpe_saed websat ferpamweb dpe_chronus dpe_plantao promocast lolitaface dpe_intranet cha_bar clinica_sorriso…
rubyasked 8 years, 6 months ago Luiz Carvalho 3,644 -
4
votes1
answer174
viewsDoubt about float field query (ruby on Rails with mysql)
Hello, I have a question regarding the database with Rails. If I declare a field to be "float", when I do the query, I need to use the ". to_float" so that Rails understands the type of this field?…