Matthias Orgler

Joined

1,260 Experience
10 Lessons Completed
0 Questions Solved

Activity

I simply added the object access one line below that (where it's explicitly about objects, not the bucket). Don't know if that's correct, but it works.

What caused this error for me were 2 things:

  1. My localhost domain was different (localhost instead of 127.0.0.1). I also had to make sure it's not accidentally https locally, because there will be no ssl. I had to make sure to get this right in the CORS policy.

  2. By default storage.yml names the bucket with the rails environment at the end (using some ERB). I kept it there, named my bucket "blabla-production" and of course got an error in "development" :P. Make sure your bucket name in storage.yml actually matches the name on S3.

Posted in Deploying our Rails Blog to Production Discussion

Why is your vendor directory so empty? Mine is choke full of all the gems (vendor/bundle/ruby/3.2.0/…) – it's a huge repo. Shouldn't we gitignore these dependencies in vendor? Should I stop using bundler (but with what do I replace it)?

Posted in Setup MacOS 13 Ventura Discussion

Any reason why you don't install asdf via homebrew directly?

Is there any answer about how to use StimulusReflex with esbuild (i.e. Rails 7 i.e. JumsptartPro)?

Thanks!

I think you can even use the Rails path helper with the place holder :id (i.e. move_todos_path(":id")) – probably better than to write urls manually :).

Posted in Introduction to Stimulus Reflex Discussion

How do you guys test StimulusReflex code? All my user acceptance specs (even with js: true) stopped working and the SR code seems to never get called :(. I also tried to test the Stimulus controllers via Jest, but that doen't really work either. Any resources on how to correctly test SR and Stimulus?

Hey, I'm constantly getting errors on Rails 6.1 and Tailwind 2:

Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
22:23:40 webpack.1 | ValidationError: Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
22:23:40 webpack.1 | - options has an unknown property 'config'.

I upgraded all webpacker and webpack stuff, installed the postcss stuff, but no luck. Is it really THAT hard to use tailwind 2 in a current Rails version?

Posted in Precompile error on hatchbox with yarn 2

I solved this by adding a yarn install to the deploy script on hatchbox:

-----> Precompiling assets...'
    # Force webpack output so we can debug errors
    if [ -w config/webpacker.yml ]; then sed -i '/webpack_compile_output/ s/false/true/g' config/webpacker.yml; fi
    yarn install
    rbenv exec bundle exec rake assets:precompile
  fi

Posted in Precompile error on hatchbox with yarn 2

After upgrading to yarn 2, I get the following error when deploying to hatchbox:

-----> Precompiling assets...
Unknown Syntax Error: Unsupported option name ("--no-progress").

$ yarn install [--json] [--immutable] [--immutable-cache] [--check-cache] [--inline-builds] [--skip-builds]
Compiling...
Compilation failed:
Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)

$ yarn run [--inspect] [--inspect-brk] ...

How can I fix this?

Ha, never mind. I had an older version of the schema on heroku, which made it incompatible with the schema on hatchbox.

I had to first deploy the latest version (including the latest migrations) to heroku before capturing the DB backup. After that I had no problems importing the data into hatchbox.

Hier is the full dump btw. It contains a bunch of errors, even though I completely dropped and re-created the empty DB.

pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 3091; 1259 9316695 INDEX unique_schema_migrations ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  index "unique_schema_migrations" does not exist
Command was: DROP INDEX "public"."unique_schema_migrations";
pg_restore: from TOC entry 3108; 2606 9316673 CONSTRAINT users users_pkey ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  cannot drop constraint users_pkey on table public.users because other objects depend on it
DETAIL:  constraint fk_rails_330c32d8d9 on table public.oauth_access_grants depends on index public.users_pkey
constraint fk_rails_ee63f25419 on table public.oauth_access_tokens depends on index public.users_pkey
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
Command was: ALTER TABLE ONLY "public"."users" DROP CONSTRAINT "users_pkey";
pg_restore: from TOC entry 214; 1259 9316599 TABLE users ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  cannot drop table public.users because other objects depend on it
DETAIL:  constraint fk_rails_330c32d8d9 on table public.oauth_access_grants depends on table public.users
constraint fk_rails_ee63f25419 on table public.oauth_access_tokens depends on table public.users
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
Command was: DROP TABLE "public"."users";
pg_restore: from TOC entry 6; 2615 9316488 SCHEMA public ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  cannot drop schema public because other objects depend on it
DETAIL:  table public.flipper_features depends on schema public
table public.flipper_gates depends on schema public
table public.gig_payments depends on schema public
table public.oauth_access_grants depends on schema public
table public.oauth_access_tokens depends on schema public
table public.oauth_applications depends on schema public
table public.users depends on schema public
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
Command was: DROP SCHEMA "public";
pg_restore: error: could not execute query: ERROR:  schema "public" already exists
Command was: CREATE SCHEMA public;


pg_restore: from TOC entry 214; 1259 9316599 TABLE users ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  relation "users" already exists
Command was: CREATE TABLE "public"."users" (
    "id" integer NOT NULL,
    "email" character varying(255) DEFAULT ''::character varying NOT NULL,
    "encrypted_password" character varying DEFAULT ''::character varying NOT NULL,
    "reset_password_token" character varying(255),
    "reset_password_sent_at" timestamp without time zone,
    "remember_created_at" timestamp without time zone,
    "sign_in_count" integer DEFAULT 0 NOT NULL,
    "current_sign_in_at" timestamp without time zone,
    "last_sign_in_at" timestamp without time zone,
    "current_sign_in_ip" character varying(255),
    "last_sign_in_ip" character varying(255),
    "created_at" timestamp without time zone NOT NULL,
    "updated_at" timestamp without time zone NOT NULL,
    "name" character varying(255),
    "roles_mask" integer,
    "mobile" character varying(255),
    "invitation_token" character varying(255),
    "invitation_sent_at" timestamp without time zone,
    "invitation_accepted_at" timestamp without time zone,
    "invitation_limit" integer,
    "invited_by_id" integer,
    "invited_by_type" character varying(255),
    "invitation_created_at" timestamp without time zone,
    "provider" character varying DEFAULT 'email'::character varying NOT NULL,
    "uid" character varying DEFAULT ''::character varying NOT NULL,
    "oauth_token" character varying(255),
    "oauth_expires_at" timestamp without time zone,
    "image_uid" character varying(255),
    "is_backoffice_admin" boolean,
    "locale" character varying(255),
    "icalendar_token" character varying(255),
    "invited_to_band_id" integer,
    "last_ical_access_at" timestamp without time zone,
    "receive_create_notification_emails" boolean DEFAULT true,
    "receive_update_notification_emails" boolean DEFAULT true,
    "receive_attendance_state_change_emails" boolean DEFAULT true,
    "receive_attendance_initial_reaction_email" boolean DEFAULT false,
    "confirmation_token" character varying,
    "confirmed_at" timestamp without time zone,
    "confirmation_sent_at" timestamp without time zone,
    "unconfirmed_email" character varying,
    "tokens" "jsonb",
    "tos_agreement" boolean,
    "tos_accepted_at" timestamp without time zone,
    "default_band_id" integer
);


pg_restore: from TOC entry 3275; 0 9316599 TABLE DATA users ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  column "provider" of relation "users" does not exist
Command was: COPY "public"."users" ("id", "email", "encrypted_password", "reset_password_token", "reset_password_sent_at", "remember_created_at", "sign_in_count", "current_sign_in_at", "last_sign_in_at", "current_sign_in_ip", "last_sign_in_ip", "created_at", "updated_at", "name", "roles_mask", "mobile", "invitation_token", "invitation_sent_at", "invitation_accepted_at", "invitation_limit", "invited_by_id", "invited_by_type", "invitation_created_at", "provider", "uid", "oauth_token", "oauth_expires_at", "image_uid", "is_backoffice_admin", "locale", "icalendar_token", "invited_to_band_id", "last_ical_access_at", "receive_create_notification_emails", "receive_update_notification_emails", "receive_attendance_state_change_emails", "receive_attendance_initial_reaction_email", "confirmation_token", "confirmed_at", "confirmation_sent_at", "unconfirmed_email", "tokens", "tos_agreement", "tos_accepted_at", "default_band_id") FROM stdin;
pg_restore: from TOC entry 3108; 2606 9316673 CONSTRAINT users users_pkey ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  multiple primary keys for table "users" are not allowed
Command was: ALTER TABLE ONLY "public"."users"
    ADD CONSTRAINT "users_pkey" PRIMARY KEY ("id");


pg_restore: from TOC entry 3128; 2606 9316706 FK CONSTRAINT subscriptions fk_rails_933bdff476 ndxchfocnrvjdp
pg_restore: error: could not execute query: ERROR:  insert or update on table "subscriptions" violates foreign key constraint "fk_rails_933bdff476"
DETAIL:  Key (user_id)=(843) is not present in table "users".
Command was: ALTER TABLE ONLY "public"."subscriptions"
    ADD CONSTRAINT "fk_rails_933bdff476" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id");


pg_restore: warning: errors ignored on restore: 9

Posted in How to Migrate from Heroku to Hatchbox.io Discussion

I always get the error pg_restore: error: could not execute query: ERROR: cannot drop schema public because other objects depend on it. It happens even if I clear all data from my hatchbox DB (using db:schema:load). This "public" schema is nothing I set up, but it seems to be a default thing from PG in the "postgres" and "template1" databases (both were automatically created). How do I get around this error?

Posted in How to debounce ActiveJobs?

How can I debounce jobs in ActiveJob?

Why I need this:
Events in my Rails app can trigger the same job independently from multiple places. But I want this job to run only once – only running the last job scheduled. I want to cancel all earlier jobs to save resources. Here is an example:

Job 1: Re-render file x
Job 2: Re-render file x
Job 3: Re-render file x
=> cancel job 1+2, only execute job 3

What I found:
Found https://medium.com/amco/sidekiq-tricks-dont-do-the-same-work-twice-378d4ee4c2d8, which implements this for Sidekiq. But I can't figure out how to do it in ActiveJob directly.

Is there a way to debounce jobs in ActiveJob?

Posted in Webpacker error from Vue.js Trello Clone Series

Ok, my mistake was, that I used webpack version 4, which is not compatible with the latest release of the webpacker gem. Downgrading webpack to version 3 solved the problem – now assets are compiled.

Posted in Webpacker error from Vue.js Trello Clone Series

I get a similar error with my own Rails 5.2/VueJS application when deploying to heroku. The application runs fine without errors locally, so I don't think a typo in my JS code could be the reason. The manifest.json file is created fine, but other than that, my public/packs folder remains empty. Any hints as to in which file I made have a typo to cause this error?

Posted in Building a Trello Clone with VueJS and Rails

Same error for me. Any solutions?
Thanks! Now I finally know where these weird occasional database connection errors came from on heroku ;). I had a fixed value for pool size in my database.yml, while using multiple threads in my puma config.