Debating whether to use service objects for your Rails or Ruby application? Found perfect gem for just that
github.com/shkm/strong_servi…
30
Ruby gotcha:
a=1, b=2, c=3
variables b and c assignments would be as expected, but a would be an array!
b => 2
c => 3
a => [1, 2, 3]
It turns out comma has height precedence than assignment and is evaluated as
a = (1, b=2, c= 3)
a = (1, 2, 3)
a = 1,2,3 same as
a = [1,2,3]
25
Testing timestamps accurately is tricky. `be_within` is a good solution to match within time range in #rspec #ruby #rubyonrails
expect(user.created_at).to be_within(1.second).of Time.now
2
34
In #ruby, we can check class variables by:
`MyClass.class_variable_get(:@@my_class_variable)`
For instance variables:
`MyInstance.instance_variable_get(:@ my_instance_variable)`
Quite helpful in debugging classes without any getter methods.
1
11
The Prisoner's Dilemma
Moral: "Be nice, forgiving but don't be a pushover"
youtu.be/mScpHTIi-kM?si=M_dM… via @YouTube
13
#activerecord #rails
Query for products with orders (P intersection O):
Product.joins(:order_items)
.distinct
Products without any orders (P - O):
Product.left_joins(:orders_items)
.where(order_items: {id: nil})
.distinct
No need to use subquery!
1
26
Hello @NCHLOfficial, All data in my connectips account including linked banks, favorite users, transaction history are lost! This poses a very serious question regarding stability/security of our critical data!
Changing text on mouse hover with just CSS!
#tailwindcss
hover + after + content
content can access attributes with attr()
1
Software Engineering is a Loser’s Game dzone.com/articles/software-… via @DZoneInc
1
3
Hi @eSewaNepal , I tried several times to pay my electricity bill last month but all of them failed. Now I've to pay a fine! Could you look into this please. I'm sure there are others with same problem.
1
4



