Questions tagged as 'ruby'

1
answer

Do not use hidden_field fields in nested forms

I would like to know if there is a better way to work with nested attributes without having to send the id of the parent object through the hidden_field field, I find it unsafe to leave this to the page. Suggestions? Here is the...
asked by 12.02.2014 / 17:22
1
answer

How to test a singleton class in Ruby?

I'm using require "singleton" to make a given class only be instantiated once. However, at the time of running the tests with rspec, I get the following error:    NoMethodError: private method 'new' called for MyClass. I'm not instantiati...
asked by 12.02.2014 / 00:57
1
answer

Use of Nested Attributes with relationship table "has_many through"

I have the following problem, I have a relationship: class Servidor < ActiveRecord::Base has_many :lotacoes, :through=>:servidor_lotacoes has_many :servidor_lotacoes end class Lotacao < ActiveRecord::Base has_many :servidores...
asked by 23.05.2014 / 23:03
1
answer

Gravatar in ruby-on-rails 3.2

Following the railscast tutorial to add an image of the site I found an information lagged with rails updates. The code to create a default image in the case of absence of registration in the gravatar site does not work as in the code below su...
asked by 10.02.2014 / 21:36
1
answer

How to use a method that is inside a class and adds two numbers in Ruby

class Soma def somar(num1, num2) @num1 = num1 @num2 = num2 result = num1 + num2 puts "O resultado é #{result}" end end adding = soma.new (1, 2) I can not understand why the following code does not work.     
asked by 06.11.2018 / 20:55
0
answers

wicked_pdf trying to use wrong version of Ruby

I'm getting this error: 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", "--margin-right", "3", "--footer-html", "file:////tmp...
asked by 01.11.2018 / 15:11
1
answer

Ruby test capybara encoding UTF-8 does not work

I created a new test project, using Ruby and Capybara for studies and I'm not understanding why it is not working. I have a very similar project in another PC, same configuration, the difference that the problem only occurs in the machine with w...
asked by 23.08.2018 / 13:46
0
answers

Burn PC screen in Ruby [closed]

I need to create a Cucumber report with video and for this I need to know if there is any Ruby gem that grabs the screen of the PC.     
asked by 15.08.2018 / 15:18
0
answers

How to use senitize_sql_like together with ilike

I'm having trouble using senitize_sql_like , along with ilike . When I use it, the query is not returning the expected value, following implementation used: scope :brand_name_by_content, -> (brand, sna) {sna.top_contents.where(sanitize...
asked by 11.09.2018 / 03:53
2
answers

Ruby Syntax

What happens in this part here? def permut(vet) return [vet] if vet.size < 2 perm = [] vet.each{ |e| permut(vet - [e]).each{|p| perm << ([e] + p) } } perm end The first few lines I understand, it will check...
asked by 17.08.2018 / 23:54