Questions tagged as 'ruby'

2
answers

Is there a correct place to load native Ruby libraries when using Rails?

In certain functionality of my application, I need to use the "open-uri" library, which is native to Ruby and does not have a library for Ruby on Rails. I'm using a require "open-uri" where I need it in the application and it's working...
asked by 06.02.2014 / 20:29
2
answers

What is the unless in Ruby command?

Can anyone explain how this unless command works in Ruby? ruby_is_ugly = false puts "Ruby não é feio!" unless ruby_is_ugly It has output "Ruby não é feio!"     
asked by 05.07.2017 / 15:55
2
answers

Struggle with for loop in Ruby

I am having difficulty dynamically displaying the contents of variables. For example: minha_var_1 = %{Um texto} minha_var_2 = %{Outro texto} minha_var_3 = %{Mais outro texto} But, I tried to display both with:...
asked by 21.11.2014 / 20:17
1
answer

Error: no implicit conversion of Integer into String (TypeError)

I chose the ruby language to learn how to program but I'm stuck in the following exercise : Write a program that asks for a person's favorite number. Add one to the number, and suggest the result as a much better favorite number I can on...
asked by 09.09.2017 / 20:16
1
answer

Why some methods have '::'

Why some methods such as Perl or Ruby: Net::FTP , have these two points; how is the construction of the methods of this class and why it is created this way (with this syntax) and not of the form currently used by current libraries: HTT...
asked by 12.03.2017 / 04:12
1
answer

Text area with image

Hello, I'm going to make a form and I do not know how to do it to include an image inside the text area, something like that. TEXT TEXT IMAGE TEXT Something of a kind for the include user to know? As it is done here in stack ov...
asked by 02.06.2017 / 13:27
2
answers

How to select record by position

Can you tell me how I can select a record by position? How would you search for Maria's record? obs: do not search by id or name I found the take in the guide, but it looks for the first and the position. ex: Person.take(3) // ele pegari...
asked by 02.12.2016 / 13:33
2
answers

select_collection in Ruby on rails

If I want to return the Active and Inactive options for me to select, I use the following code in the view, so it returns the 2 statuses: > <%= select(:student, :status, Situation.all.collect { |c| [ c.descricao, c.id ] }) %> But I...
asked by 14.09.2016 / 15:43
3
answers

Print Variables in Ruby

How to print two variables on the same line (without jumping)? I've tried using print instead of puts but it did not work.     
asked by 30.04.2016 / 18:09
1
answer

Best way to return data entered by a select of constants

I have a Usuario template and for it I have two constants that define a type for it. To pass this information to a select I have a type method that returns a Array . Ex: #models/Usuario.rb class Usuario < ActiveRecord::B...
asked by 13.03.2014 / 15:48