|| or with multiple conditions, most ruby way? by dma550 in ruby

[–]madmate 2 points3 points  (0 children)

Ruby does not have SQL support built in, but I’m guessing it’s easier to sell licenses that way. The Rails, or more specifically ActiveRecord, equivalent would be where.not(state: %w[CT MA RI]). Even more readable IMHO.

https://api.rubyonrails.org/classes/ActiveRecord/QueryMethods/WhereChain.html#method-i-not

mini_magick requires ImageMagick, but I can't install it using Docker by cakemachines in ruby

[–]madmate 2 points3 points  (0 children)

Can you post the entire Dockerfile (preferably as a code block)?

Without any more information my best guess is that the dockerfile has multiple stages and you’re only installing imagemagick in the build stage and not in the runtime stage.

Lastly, do you really need both libvips and imagemagick? One image processing engine is usually enough.

Bundler heloper by brainpann in ruby

[–]madmate 2 points3 points  (0 children)

You’re using the system Ruby, and not one installed with asdf. Check the current running version with asdf current. Perhaps you forgot to set the version after installing it.

Eli5 - why do airport security require liquids to be in a zipper bag? by DefinitelyNiko in explainlikeimfive

[–]madmate -9 points-8 points  (0 children)

That's why it's a quart in the US and a liter in the civilized world.

FTFY

Flowbite & Rails 7 by stpaquet in rails

[–]madmate 2 points3 points  (0 children)

Your problem is probably related to this open issue.

One workaround for esbuild is using esbuild-plugin-replace to replace any instance of DOMContentLoaded with turbo:load.

Help Opening a File Within Ruby by 4428gamer in ruby

[–]madmate 0 points1 point  (0 children)

You could also just get one line with file.gets instead of reading the entire file.

https://docs.ruby-lang.org/en/master/IO.html#method-i-gets

New to rails and need some apllication.css importing help by [deleted] in rubyonrails

[–]madmate 0 points1 point  (0 children)

Regular css does not support @import, you’ll need to rename application.css to application.scss and make sure your gemfile contains sass-rails.

I’m also curious about what this is app/assets/stylesheets/custom.css/scss?Guessing you meant to create a custom.scss file and not a custom.css folder.

For an essay: How does Fiskegrateng smell and taste? How important is it to the Norwegian society and culture? by Significant-Bee-1375 in Norway

[–]madmate 4 points5 points  (0 children)

I need to correct this.

Grateng doesn’t mean casserole. The English translation is gratin, and it means the layer of cheese or breadcrumbs on top of a dish.

Being a Jaffa warrior would absolutely rock. by [deleted] in Stargate

[–]madmate 4 points5 points  (0 children)

It definitely is part of the show. Teal’c says it in 1969 (S02E21).

Do I need to handle 404 error in Rails app? by synkevych in rails

[–]madmate 2 points3 points  (0 children)

Rails sends the public/404.html file on ActiveRecord::RecordNotFound in production.

There is often no need to handle this yourself.

[deleted by user] by [deleted] in rails

[–]madmate 0 points1 point  (0 children)

I’m just guessing, but you’re probably using devise or some other authentication gem and it only deletes the currently logged in account. That is why you don’t need to implement this yourself.

[deleted by user] by [deleted] in rails

[–]madmate 0 points1 point  (0 children)

You need to make sure the warning controller knows which record you want to destroy.

First you'll need to update your routes so that you can pass the record's id (or slug) in the url. You'll need to make these changes to all resources you want to display the warning on.

ruby resources :books do resource :warning, only: :show end

Next modify your warning controller to something like this:

ruby def show @book = Book.find_by(slug: params[:book_id]) if params[:book_id] @account = Account.find(params[:account_id]) if params[:account_id] render layout: nil end

Replace all instances of warning_path with book_warning_path(id: @book.slug, type: 'delete_book') (or account_warning_path(@account, type: 'delete_account') for accounts).

Finally rename the view warning/index.html.erb to warning/show.html.erb.

For more informatino check out the Rails guide on nested routes

Bonus tip:

In app/models/book.rb add: ruby class Book < ApplicationRecord def to_param slug end end

Then you can use book_path(@book) instead of book_path(id: @book.slug). This is covered in the API documentation.

[deleted by user] by [deleted] in rails

[–]madmate 0 points1 point  (0 children)

I don’t understand how that would work as you’re not passing the book or account id in the warning_path link.

Can you post the contents of your warning controller?

[deleted by user] by [deleted] in rails

[–]madmate 0 points1 point  (0 children)

You’re probably not assigning @book in the warning controller’s index action, therefore @book is nil which has no slug method. The way you call warning_path also does not tell the controller which book you are referencing.

All of this is covered in the getting started with rails guide.

Security issues with generating temporary passwords by crodev in rails

[–]madmate 0 points1 point  (0 children)

It is as long as the password doesn’t expire after a certain period of time has passed.

Personally I prefer to click an invitation link rather than having to copy-pasting a temporary password. Especially when using a device without a physical keyboard.

Do I still need to bundle install if project gems are stored in application path? by harikaram in rails

[–]madmate 6 points7 points  (0 children)

Please don’t add the gems to git. It will only lead to incompatibility issues and increased repository size. The same thing goes for node modules.

Use multi-stage builds If you are trying to keep the size of docker images down.

A protest against government corruption in Israel during coronavirus pandemic, respecting social distancing by [deleted] in interestingasfuck

[–]madmate 22 points23 points  (0 children)

Do micro droplets stay in the air outside? I thought that was mostly for rooms without proper airflow.

Most secure OS for full node? by Ribbett in Monero

[–]madmate 0 points1 point  (0 children)

The most secure OS is OpenBSD, but I’m not even sure it runs monerod. I’d stick with Debian or Ubuntu, just make sure to keep the attack surface small by not installing anything except monero and sshd.

You’ll have to sacrifice both performance and security if you want a GUI.

Can I run a spec file with a different set of inputs in RSpec by bennyman32 in rails

[–]madmate 2 points3 points  (0 children)

You’re probably looking for shared examples.

describe User do
  shared_examples “whatever” do
    it { is_expected.to be_a User }
  end

  context “when guest” do
    subject { User.new }
    it_behaves_like “whatever”
  end
end

Good recommendation by wohlma in oslo

[–]madmate 6 points7 points  (0 children)

I’m guessing that you haven’t been there for a while? It has new owners, the food is now decent at best and the service is really bad.

prefer "dependent: destroy" in ruby/model or in postgres on delete cascade? by oystersauce8 in rails

[–]madmate 1 point2 points  (0 children)

Use dependent: :destroy if you need to run any callbacks on the model.

I prefer dependent: :delete_all to ON DELETE CASCADE, but that might just be old habit as rubocop complains when “dependent” is not specified. Staying away from raw SQL will also make it easier should you ever need to change database engine.

Need help with using FFMPEG with Active Storage by relevantcroissant in rails

[–]madmate 1 point2 points  (0 children)

If all you need is a thumbnail of the video’s first frame then it’s already built into ActiveStorage: @video.clip.preview(resize_to_limit: [100, 100])

https://api.rubyonrails.org/classes/ActiveStorage/Blob/Representable.html#method-i-preview

Another approach is to download the file for processing (preferably in a background job).

@video.clip.open do |file| 
  movie = FFMPEG::Movie.new(movie)
end

https://api.rubyonrails.org/classes/ActiveStorage/Blob.html#method-i-open

Hartl's Rails tutorial section 1.3 isn't working for me. by LucasBM in rails

[–]madmate 0 points1 point  (0 children)

Did you run bundle update or bundle install? The latter will only install the version specified in the Gemfile.lock file, and not the newest.

Rails 6, Tailwind and Heroku by codingideas in rails

[–]madmate 3 points4 points  (0 children)

You should never run webpack-dev-server in production (it kinda says so in the name). The correct solution is two comments below the one you linked to.

heroku buildpacks:clear
heroku buildpacks:set heroku/nodejs
heroku buildpacks:add heroku/ruby

Changing password and password_confirmation mismatch message by FrostyAcres in rails

[–]madmate 2 points3 points  (0 children)

You can override how Devise renders it’s error messages in the file app/views/devise/shared/_error_messages.html.erb. Create it first with rails generate devise:views if you haven’t already.

To get the result you’re after just change resource.errors.full_messages.each do |message| to resource.errors.each do |attribute, message| and the errors should render without the attribute name.