I created a class called CalculateLocalPattern in Rails.
The following is the initialize method that is executed immediately after CalculateLocalPattern.new ().
# app/models/calcurate_local_pattern.rb class CalcurateLocalPattern Array, y_coo =>Array @x_coo = x_coo @y_coo = y_coo @coo = x_coo.zip (y_coo) end attr_accessor: x_coo,: y_coo,: coo (Omitted) end
I wanted to test with the Rails console and set the array to two arguments. Then
I was angry with
x = [1, 2] y = [3, 4] test = CalcurateLocalPattern.new (x, y) Traceback (most recent call last): 1: from (irb): 3 ArgumentError (wrong number of arguments (given 2, expected 0..1))
Also, if you try without any arguments,
test = CalcurateLocalPattern.new Traceback (most recent call last): 2: from (irb): 1 1: from app/models/calcurate_local_pattern.rb: 3: in `initialize ' ArgumentError (wrong number of arguments (given 1, expected 2))
It will become. (There seems to be an error in initialize, so you should still need two arguments)
I think "wrong number of arguments" is an error that the number of arguments on the calling side is different from the number of arguments on the method side.
What causes the expected number of method-side arguments to change depending on the argument settings?
Tell someone.Version information
Answer # 1
ApplicationRecord defines "initialize", so if you define it with its children, various things will happen.
Did you make a child of ApplicationRecord, did you migrate and create a table in the DB?
If so, please update with the corresponding parameters.
- ruby - the wrong number of arguments (given 5, expected 2) is not fixed
- ruby on rails 5 - wrong number of arguments (given 0, expected 1) cannot be resolved
- ruby on rails - dealing with wrong number of arguments (given 1, expected 2)
- ruby on rails - i want to resolve rails wrong number of arguments
- ruby on rails 6 - the delete function cannot be implemented well
- ruby - asynchronous communication of like function cannot be implemented
- ruby - logout function cannot be implemented
- php - csv download of data cannot download when the number of columns increases
- [ruby + selenium] how to get the number of characters for each individual page
- ruby on rails - get results in argumenterror (wrong number of arguments (given 1, expected 0)):
- ruby on rails - data cannot be saved in the intermediate table (parameters cannot be passed)
- ruby on rails - cannot pass id to destroy action of intermediate table
- ruby on rails 5 - actioncontroller :: invalidauthenticitytoken cannot be resolved
- ruby on rails runtime error cannot be resolved
- ruby on rails 5 - the time notation cannot be written normally
- ruby nokogiri some parts cannot be obtained
- about passing ruby arguments (arrays)
- ruby - cannot save to database
- ruby - the method defined in the model cannot be used
- ruby - i entered secret_key_base, but http error 500 cannot be resolved
- html - i want to allow users to use points
- ruby - i can't get the value from the array i earned with news-api
- ruby - items duplicated by cocoon are caught in forbid_login_user and are not saved
- ruby - about implementation of tag function in rails
- ruby - i want to display only the image of the logged-in user when executing the search function
- ruby - [rails] i can't install the add favorite button
- how to unlock excel with password with ruby
- ruby - i want to display an error message when posting/editing fails by validation check
- ruby - [rails] when rails s is executed, an error "cannot load database configuration" appears and it is forcibly term
- ruby - about the error when there is no id of the association destination