Questions tagged as 'ruby'

2
answers

How to manually delegate an object in Ruby

To better understand meta-programming in Ruby I would like to make an object, when instantiated, delegate all methods of an object passed as a parameter. And your class will delegate the methods that the class contains. However, I would like Obj...
asked by 24.01.2015 / 01:01
1
answer

Pelican: How to define the layout of each page similar to Jekyll?

I use Jekyll in my website / a>, I'll stop using that reason . I wanted to migrate to the Pelican but caught up with the layouts. The problem is this: In Jekyll I can on each page define the layout, or rather tell (point) what the la...
asked by 18.09.2014 / 21:32
1
answer

How to use authentication in Sinatra?

What would be the best way to do authentication in applications built with Ruby / Sinatra? Devise I know it does not work. I have tried several tutorials with Warden, but the settings are very complex and confusing as I see it. Simple authentica...
asked by 15.08.2014 / 05:46
1
answer

How to get related data in Ruby on Rails?

Hello. I have an application where User has_many Status . And Status has_many Likes . How do I get the total likes a user has? For example, it has 2 statuses with 10 likes each, which gives a total of 20 likes. How d...
asked by 20.08.2014 / 00:52
2
answers

Matcher be_true ruby / rspec

I'm starting to study about ruby / rspec following a book, but I'm not making progress using matcher be_true . The following is the error: BagOfWords#push is possible to put words on it (FAILED - 1) Failures: 1) BagOfWords#push is p...
asked by 22.10.2014 / 02:21
1
answer

Problem running test controller in rails 4

Good afternoon, I generated a scaffold of a class of mine, example User. When running the tests I came across the following failure: Minitest::Assertion: "User.count" didn't change by 1. Expected: 3 Actual: 2 test/controllers/users_contr...
asked by 30.07.2014 / 21:59
1
answer

Relationship has_and_belongs_to_many Rails 4

I have an Item has_and_belongs_to_many template: gender and a Gender template has_and_belongs_to_many : items, also a relationship table generos_itens (id_item, genero_id). I'm trying to create a new relationship between item and gende...
asked by 19.05.2014 / 21:11
1
answer

activerecord is not saving the relationship

I have such a relationship in rails class ReducaoZ < ActiveRecord::Base self.table_name = 'reducaoz' has_many :aliquotas, foreign_key: 'reducaoz_id', class_name: 'Aliquota', dependent: :delete_all end class Aliquota < ActiveReco...
asked by 22.05.2014 / 16:11
1
answer

Validating a template with scope in Ruby on Rails

Suppose the models: class A < ActiveRecord::Base has_many :bs end class B < ActiveRecord::Base belongs_to :a has_many :cs end class C < ActiveRecord::Base belongs_to :b end If I want a C attribute to be unique in B's scop...
asked by 12.05.2014 / 14:27
1
answer

Display error message correctly

I have this code: flash[:error] = t("errors.messages.restrict_dependent_destroy.many") and the system displays the following error message:    Can not delete the record because there are % {record} dependents I want it to show this...
asked by 13.05.2014 / 14:09