/r/ruby

Photograph via snooOG

Celebrate the weird and wonderful Ruby programming language with us!

A sub-Reddit for discussion and news about Ruby programming.

Learning Ruby?

Tools

Documentation

Books

Screencasts

News and updates

/r/ruby

83,922 Subscribers

9

SF Bay Area Ruby Meetup on May 16 ⏰ @ New Relic

Bay Area Ruby and Rails engineers,

It's time to meet, share stories from the recent RailsConf 🔥, and make new Ruby friends 😺.

We are gathering this Thursday, May 16, at the New Relic HQ at 5 PM. Our amazing speakers–Cameron Dutro, Sweta Sanghavi, Yatish Mehta and Kayla Reopelle–will provide food for thought, while New Relic supplies drinks and appetizers. Got questions for fellow Rubyists? Bring them over!

Sign up, and see you there 💖
https://lu.ma/sfruby-may24

0 Comments
2024/05/11
03:06 UTC

2

Need help using --user-install

I currently run a blog using Github Pages and HTML. I am currently trying to switch from using HTML to using markdown and Jekyll. I am using the guide published by Github in order to do this. After I created a new jekyll site like the guide told me using --skip-bundle. I was confused here because I couldn't find a Gemfile, so I manually created one and added the gems like the guide told me. When I tried to do bundle install, it said it didn't have the proper permissions. I tried root, but after it gave me the warning I didn't finish using it. The I tried suffixing bundle install with --user-install, it gave me the message "Unknown switches "--user-install" ". I will be on here if you need any more clarification, please help me figure out how to install the gems.

5 Comments
2024/05/10
21:47 UTC

10

Packwerk - is there a way to build upon namespaces, not single directory?

I am trying to get around adding packwerk to our existing code base, but I've got stuck with what seems to be a very basic thing. Is there a way to consider a “package” based on the namespace, not file location?

In a typical Rails app, files from the same namespace reside in multiple paths, for example app/models/admin/… and app/services/admin/… etc. Adding package.yml to any of this directories ignores the other dir. If I add package.ymlto many subdirectories, those are considered separate packages, even though they reside into a shared namespace.

I've briefly looked into other tools, but they all seem to lean towards putting everything into isolated directory and build the structure up there. That might work, but requires huge effort to get everyone aligned, etc. Besides, if we could simply put all the stuff into one subdir, the Engine (or even a separate Gem) would do the job here. I was quite excited to get some nice boundries defined, but having shared namespace in 5+ more directories (presenters, forms, models, services, etc, etc) makes this kind of useless. Setting package and interconnecting deps for all those subdirectories seems like a huge overhead).

I just briefly looked into other extensions, tools related to isolation, but haven't found anything to answer above question.

4 Comments
2024/05/10
08:29 UTC

18

Help switching to Ruby

Hi there. I’ll try to keep this as brief as I can. I’ve been working at a SaS company for a few months in a customer-facing non-technical role and I really enjoy it. It’s relatively small, <50 staff members with ~180,000 active users and I have a have a very small bit of programming experience (came from a scientific background in research and had to overcome an obstacle in analysis by teaching myself Python). Of course my skills/experience/knowledge in that regard probably isn’t even 1% of any one of our actual Devs but I’m really interested in learning more about Ruby in my spare-time to see if this could help bolster my position at the company. I’m not under any illusion that I will transition to the technical side of the company but I think if I could gain more experience this might benefit dialogue with the developers on a range of different things.

If anyone could suggest resources/starter projects or anything like that I would be very grateful.

Apologies if this post is hopelessly naive/a fool’s errand.

20 Comments
2024/05/10
07:55 UTC

4

Files not being Read!?

I am a new Ruby developer learning it for my dad, a Ruby developer so I can do a project with him. I'm trying to figure out how to read and write files in Ruby to store data. I followed a tutorial but it's not working for me. I'm not getting an error because the rest of my unrelated code is working. This is the code I've written:

teams = File.open("people.txt")
p teams.split

This is my weird output:

#<File:people.txt>

THIS HAS BEEN SOLVED

8 Comments
2024/05/10
00:39 UTC

8

What are best practices to define #hash and #eql? on a Ruby class. What about inheritance?

Given I have a simple class like:

class Person
  attr_accessor :id

  def initialize(id:)
    @id = id
  end

  def eql?
     raise NotImplementedError
  end
  alias == eql?

  def hash
    raise NotImplementedError
  end
end

I'm aware of Struct and Data classes and they are out of the question.

I'd like to consider two people the same using Ruby classes. Let's say that if they share the same id then they are considered eql and two instances with the same id if would return the same value in a Ruby Hash too. Note: I chose :id to make it simple here but id could be computed from a collection of attributes too.

Additional Questions: What would be the correct approach/design if we consider that Person can be inherited?

class InheritedPerson < Person; end
  • Should #eql? be true?
    • assert Person.new(id: 1).eql?(InheritedPerson.new(id: 1))
  • Should #hash be the same?
    • assert_equal Person.new(id: 1).hash, InheritedPerson.new(id: 1).hash
4 Comments
2024/05/09
23:13 UTC

0

Question about porting NPM packages to Ruby Gems

Hi, was wondering if anyone is able to get paid (maybe in a consulting gig) to port node modules to Ruby Gems? Are there any guides on how to do this? Is it fun/easy to do? Any popular examples of this?

5 Comments
2024/05/09
20:40 UTC

31

John Hawthorn | Vernier: A next Generation Ruby Profiler

1 Comment
2024/05/09
20:29 UTC

5

Blueprints to generate code in the bespoke style of the developer/team/company/codebase

1 Comment
2024/05/09
15:59 UTC

3

Requirements issue

I'm running on a 24.04. ubuntu docker container with master branch RVM. Whenever I try to install one of the newer rubies with it, libncurses5-dev always tries to install. Problem is that the package is not available on ubuntu 24.04. Anyone knows why and if there's a way to prevent it? It's making me type in a password for essentially nothing, which prevents me from installing the ruby in the Dockerfile.

4 Comments
2024/05/08
09:29 UTC

17

Ruby on Rails puma with and without nginx

Hi Ruby community,

i am a new Ruby/Ruby on Rails user (gems are kinda cool) and i was wondering why an nginx is used before the puma. Would it actually matter if i don't use anything in front of the puma? Does anyone know if there are any benchmarks with/without using nginx?

I only managed to find this so far: https://keita.blog/2020/05/24/rails-on-aws-is-nginx-required/

Also, does anyone know best practices of using puma?

Thanks!

3 Comments
2024/05/07
16:55 UTC

1

Json gem installation issues, "bundler failed to load command jekyll"

https://preview.redd.it/ayajg0gxgvyc1.png?width=1558&format=png&auto=webp&s=3047326eccd1789d5c169a4abfeab584161a6d8e

Using Arch in WSL and interacting through VSC. Bash terminal. This was a completely fresh installation at this point.
---Steps I followed---
Installed bash-completion, ruby, and updated system
sudo pacman -Syu ruby bash-completion
gem install jekyll bundler
Edited my bashrc to include the following per arch wiki
export GEM_HOME="$(gem env user_gemhome)"
export PATH="$PATH:$GEM_HOME/bin"
cd'd into the dir and ran this
jekyll new .
No problems at this point. Then I used this command.
bundle exec jekyll build

I got the wall of issues here, which seems like the json gem isn't installed. I tried installing it manually and checked to make sure it installed locally which it did but I still get the same problem. Has anyone else had this issue?

1 Comment
2024/05/06
21:17 UTC

6

Ruby/Cucumber Automation dev career has stalled - why didn't I see this coming?

I sort of fell into working with ruby. I went to college for city planning, "learned how to build websites" from lynda .com, bought a few books to teach me more. Had fun with it for a few months. Learned some javascript (or jQuery I should say). Learned a little php/mysql - enough to sort of understand things but not enough of any of it to really know what I am doing. This was 10-12 years ago. Ended up getting a few interviews but landed nothing.

Eventually got into manual testing which led to automation testing and working in a ruby/cucumber framework. I have been doing that for the last 5 years. About 2 and half years ago I moved to a new team and with it was given the opportunity to create a new testing framework. I really enjoyed that work and for about a year or so there was enough development to keep me satisfied. For the the next 12 months it got a bit boring with less dev work needed. The last 6 months the writing has been on the wall that another group developed another framework using a jasmine framework for webdriverio.

I was essentially wasn't given an option - my framework is done, theirs is the new one moving forward (lots of politics that aren't relevant here).

The whole time I have worked in automation I have basically been self taught. I am sure that comes with a lot of bad habits but I have tried to do better. I was lucky enough to pick up a second job in 2022 (started and ended) and worked in a java/cucumber framework. Learned some java which I thought I would never do, didn't hate it but still prefer ruby. Haven't touched anything else since though.

I am now looking for a new job. I would love to stay in ruby but everything I can find is basically just rails. I have no confidence in my abilities (even though I built a better framework that we had while learning what I know of java now). I fear that not having much of a mentor or formal education has me in a position to unlearn before relearning.

Essentially I feel like I have wasted years and pigeonholed myself into a skill set that is dead. Not that ruby is dead, but ruby/cucumber automation is. For that matter, most of the automation roles I am finding aren't even ruby/java. They are c# or cypress and are asking for years of experience.

Where do I go from here? I am still employed but being moved into a release management type of role. I don't know if I will enjoy it or hate it, succeed or fail. I need a bigger paycheck and my position change isn't coming with a raise.

I like ruby and think I would like to keep working with it, but I have no rails experience. I am lost and hoping some internet strangers have some good advice for me. Thanks in advance if you do.

5 Comments
2024/05/05
23:13 UTC

Back To Top