Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 7.2.1 issue. ArgumentError: wrong number of arguments #135

Open
yunixon opened this issue Sep 11, 2024 · 3 comments
Open

Rails 7.2.1 issue. ArgumentError: wrong number of arguments #135

yunixon opened this issue Sep 11, 2024 · 3 comments

Comments

@yunixon
Copy link

yunixon commented Sep 11, 2024

Get error with rails 7.2.1

@alert.mark_as_read! for: @current_user

ArgumentError: wrong number of arguments (given 1, expected 2)

return to rails 7.1.4 and works good

Diff:

Using activesupport 7.2.1 (was 7.1.4)
Using activemodel 7.2.1 (was 7.1.4)
Using activerecord 7.2.1 (was 7.1.4)
Using activejob 7.2.1 (was 7.1.4)
Using actionview 7.2.1 (was 7.1.4)
Using actionpack 7.2.1 (was 7.1.4)
Using actionmailer 7.2.1 (was 7.1.4)
Using railties 7.2.1 (was 7.1.4)
Using actioncable 7.2.1 (was 7.1.4)
Using activestorage 7.2.1 (was 7.1.4)
Using actiontext 7.2.1 (was 7.1.4)
Using actionmailbox 7.2.1 (was 7.1.4)
Using rails 7.2.1 (was 7.1.4)
@ledermann
Copy link
Owner

Fixes for Rails 7.2 are not released yet. Please try this:

gem 'unread', github: 'ledermann/unread'

@yunixon yunixon changed the title Rails 7.2.1 issue. ArgumentError: wrong number of arguments wrong number of arguments Rails 7.2.1 issue. ArgumentError: wrong number of arguments Sep 11, 2024
@chriswnl
Copy link

chriswnl commented Oct 9, 2024

7.2 support now seems to be there but I'm getting issues caused by the precision on timestamp on ReadMark vs datetime on my rails models.

This only came to light in dev while immediately marking an issue read under :show in the controller. That creates a timestamp on the read_mark without milliseconds while the datetime column on the model supports milliseconds.

This results in the read_mark appearing to be created before the associated record.


[#<ReadMark:0x0000717b61e4f798
  id: 9,
  readable_type: "Issue",
  readable_id: 6,
  reader_type: "User",
  reader_id: 1,
  timestamp: "2024-10-09 10:00:53.000000000 +0000">] 
3.3.1 :011 > i
 => 
#<Issue:0x0000717b621acf80
 id: 6,
 subject: "test this please",
 description: "let's see",
 user_id: 1,
 created_at: "2024-10-09 10:00:53.231852000 +0000",
 updated_at: "2024-10-09 10:00:53.231852000 +0000"> 

My fix was to change the migration adding precision: 6

def self.up
  create_table ReadMark, force: true, options: create_options do |t|
    t.references :readable, polymorphic: { null: false }
    t.references :reader,   polymorphic: { null: false }
    t.datetime :timestamp, null: false, precision: 6
  end

  add_index ReadMark, [:reader_id, :reader_type, :readable_type, :readable_id], name: 'read_marks_reader_readable_index', unique: true
end

@smgdkngt
Copy link

smgdkngt commented Oct 12, 2024

If someone is looking for a migration for the solution from @chriswnl:

class AddPrecisionToReadMarks < ActiveRecord::Migration[8.0]
  def change
    change_column :read_marks, :timestamp, :datetime, precision: 6
  end
end

Maybe unrelated to this, but with Rails 8 I also ran into issues when immediately marking a created entity as read. For now I manually increase the timestamp by 1 second 🫤

current_user.read_marks.where(readable: things).update_all("timestamp = timestamp + interval '1 seconds'")

I'm using postgres btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants