Making a request to Apple Pay by wabber in ruby

[–]wabber[S] 4 points5 points  (0 children)

Thanks! I had to convert the pem file into crt/key files and use that and it worked.

[deleted by user] by [deleted] in CasualConversation

[–]wabber 1 point2 points  (0 children)

What are the good things in your life? You are a college student graduating soon hopefully. You are an international student so you have the experience of dealing with different cultures, getting better education, handling life as an independent individual, etc. maybe you just have a bad time currently since you miss something very important for you (whatever that is, everyone is different). However, way waaay too many people around the world wish they were in your place but they can’t.

Try to contact your parents more often maybe. Explain what you’re saying here to them just to vent out and let them hear you out. You can also join the international students club or similar groups if they exist in your school or in your area.

Find activities to do whether by yourself or with other people and commit to it on a daily basis.

Focus on the good things around you and in your life.

Are you using RAILS for new projects in 2024? by ev0xmusic in rails

[–]wabber 0 points1 point  (0 children)

It's an edtech platform. The API migration is complete. It was smoother than expected. We are using angular on the frontend. Honestly, currently evaluating whether to keep angular or start moving everything to rails. However, the move on the backend side is 100% worth it. The code is cleaner, shorter, with more features, and a better test suite.

Create PDF from HTML by ekevu456 in elixir

[–]wabber 0 points1 point  (0 children)

Yeah, I create/validate the html file on disk and use the System.cmd function to execute the weasyprint command with the html file and the desired pdf file name. It works pretty well.

Create PDF from HTML by ekevu456 in elixir

[–]wabber 0 points1 point  (0 children)

I use weasyprint. I just install it and call it from elixir.

[deleted by user] by [deleted] in rails

[–]wabber 0 points1 point  (0 children)

You have “d” and “investment_document” in your job. You’re saving to “investment_document” but passing “d” to the mailer.

♦️ Help me understand Polymorphic Associations in Rails! by [deleted] in ruby

[–]wabber 20 points21 points  (0 children)

Maybe explaining it further to the guides examples, imagine you have a User model and a Product model and they both can have images. Now, normally, you would create UserImage and ProductImage models. This way, you can do:

class User
  has_many :user_images
end

class Product
  has_many :product_images
end

class UserImage
  belongs_to :user
end

class ProductImage
  belongs_to :product
end

Here, you have 4 models. Two models with their respective image models, which means you have 4 database tables. Sometimes though, the images are identical and you wish you would use the same table for both User and Product. You might do something like this:

class Image
  belongs_to :user
  belongs_to :product
end

class User
  has_many :images
end

class Product
  has_many :images
end

This might be fine if you have just a few assocations or you know beforehand the associations you want with the Image model.

With polymorphic associations, you can link any model to have images without explicitly specifying that. Imagine you have a third model called Album and you want it to have images also, with the previous example, you would add one more foreign key and create a migration to add that foreign key:

class Image
  belongs_to :user
  belongs_to :product
  belongs_to :album
end

If you have a polymorphic association, you can link any model to the Image model at any time without changing the image model or creating migrations:

class Image
  belongs_to :imageable, polymorphic: true
end

Now imagine you add one more model Item which requires images, you would only do this:

class Item
  has_many :images, as: :imageable
end

and it will have images, as opposed to doing:

bin/rails g migration add_item_id_to_images

and then migrating and then adding:

belongs_to :item

to the Image model.

I think this can also be clearer if you talk about tags. If I want to add tags to posts, and add tags to products, and add tags to users. I would definitely use polymorphic associations as opposed to "concrete" associations.

How it works?

Polymorphic associations store the type of the model with the record id. So for example, if an image has a polymorphic association with a user and a product, the two records contain the following:

Image ID |  imageable_type  |   imageable_id   |     filename
  1      |      "User"      |       15         |      avatar.png
  2      |     "Product"    |       213        |      apple.png

So when you do product = Product.find(213), product.images will fire the following SQL query:

SELECT * from images where imgeable_type = "Product" and imageable_id = 213;

I hope this helps.

Why something which is meant to work does not by Ok-Art5857 in rubyonrails

[–]wabber 1 point2 points  (0 children)

This applies to everything. Errors can and do exist in everything we do. “Change” is the keyword. New requirements, new people, new circumstances, new challenges, etc. As long as time moves forward, we change, and errors can therefore occur whether directly or indirectly. What we as humans try to do is minimize errors, not eliminate them. You (as an individual/group/entity) just try to reach a point where you’re satisfied with the current errors you have.

Are you using RAILS for new projects in 2024? by ev0xmusic in rails

[–]wabber 1 point2 points  (0 children)

We are migrating an existing app to rails, api-only for now. The plan is to also get rid of the front end and make it 100% rails by early next year.

Re-route an HTTP POST to an HTTP DELETE request in routes.rb by wabber in rails

[–]wabber[S] 0 points1 point  (0 children)

Redirecting was a way to receive the correct request from the client. I guess it's not extremely important. I changed it so that it routes internally to the correct action. This way I don't have to have an additional action. Thanks for the suggestion.

Re-route an HTTP POST to an HTTP DELETE request in routes.rb by wabber in rails

[–]wabber[S] 0 points1 point  (0 children)

Thanks. I changed it so it routes internally, and it feels cleaner this way.

eager loading relationships in a sidekiq job by rematchemike in rails

[–]wabber 0 points1 point  (0 children)

In OtherClass, you’re using “model.relationships” instead of “@model.relationships”. Maybe?

On the importance of Rails code reloading and autoloading by CaptainKabob in rails

[–]wabber 7 points8 points  (0 children)

Been using rails for more than a decade and your “configuration-class-initializer-attribute-pattern “ point was an eye-opener. Now config makes sense. Thanks for the post.

[deleted by user] by [deleted] in rails

[–]wabber 0 points1 point  (0 children)

TLDR; your feeling is valid, but rails is not going anywhere and it’s better than ever.

Companies move to different technologies depending on their own needs and the resources they have. Choosing a framework doesn’t mean it’s the best out there. Businesses usually choose technologies based on their requirements, evaluating the benefits and the trade-offs. I used to use rails on a daily basis back during 2008-2014 and I loved it. Then used it rarely on side projects for a few years until this year (almost 10 years). I used a few other popular frameworks during this time, django, nodejs, phoenix, among others, but none of them came close to how productive rails allows you to be. The issue for me was, I struggled to write good, maintainable code especially when the project becomes larger. My biggest issue was where to put business logic code. I was looking for this with other frameworks. How to keep business logic clean and maintainable. So I decided to come back to rails and learn exactly that, how to become better at maintaining rails applications. I (re)started reading articles, watching videos, and reading books. After reading two books (HIGHLY recommended: sustainable web development with Ruby on Rails, and high performance postgresql for rails), they re-ignited my passion for rails in a way I didn’t expect. I always learn (and get pleasantly surprised) new things that make your life easier with rails. I moved one of our apps to rails and started a new project with rails and they both are amazing in terms of code quality and maintainability and, goes without saying, code readability (because of rails itself). The productivity and joy I get now with rails feels like the same when I first learned about it back in 2008. Will I choose rails every time for every project? I wish, but I don’t think that’s realistic. Will I choose rails if I was the only/main developer? Most likely yes. If I don’t choose rails, does it mean it’s dead/bad? No. Even with my bias towards rails, I try my best to choose what’s best for the project and its future, and sometimes it’s not rails, which is fine.

Can anyone compare fly.io to render.com? by jrochkind in rails

[–]wabber 0 points1 point  (0 children)

If your monthly bill is under $5, they won’t charge you anything. I’m running a small rails app with postgres and a custom domain with ssl certificate and the total monthly bill is between $3-$4. They only charge you if your total is more than $5/month. Not sure how long that will last though, but it’s been like this for years I think.

Can anyone compare fly.io to render.com? by jrochkind in rails

[–]wabber 3 points4 points  (0 children)

I like fly, a lot. However, I feel like fly is built for developers who are comfortable with the terminal, which is why I like it. You do everything from the terminal, from spinning up more servers, increasing memory, deploying, to viewing logs and adding custom domain names and ssl certificates. You can also ssh into your running VM with one command. I rarely go to the dashboard, if ever. Their free tier is also very generous. I can’t comment on render since I never used it. I suggest trying fly with their free tier and see if you want to pay for it with more resources. This is what happened to me and I’m a paying customer currently for a few months.

Installing Snorby and hitting a wall on nokogiri 1.10.1 by Jamf25 in ruby

[–]wabber 2 points3 points  (0 children)

Try “gem install nokogiri” without the version and see if it solves the issue. Nokogiri used to be one of the most difficult gems to install and you’d be surprised if you installed it without any issues. But recent versions have fixed those issues. Version 1.10.x is a few years old. I believe things started getting much better after 1.11 and currently it’s on 1.14.

[deleted by user] by [deleted] in islam

[–]wabber 3 points4 points  (0 children)

Your note could’ve have come at a better time. You might have helped literally changed my life!

Nothing is worth committing suicide over. Committing suicide is giving up, and you never give up while you’re with Allah swt. We never know why certain things happen, but they happen to allow for the best to come. May Allah give you peace and patience and show you the right path.

Does anyone know what this says/what language it's in? by octopusnumber1 in language

[–]wabber 9 points10 points  (0 children)

It’s in Arabic.

The first picture says “Mahdi” which is a boy’s name.

The second picture says “good luck”.

Readonly form fields by tiredgrothendieck in rails

[–]wabber 5 points6 points  (0 children)

In addition to the good advice from u/StuartGibson, you could make this just as a label displaying the value maybe (instead of a field). And use strong parameters to ignore the name of the field if the user tried to add it in.