I can't seem to resolve this.
I want to accomplish this without a database :
Object.new(:attribute_1 => "foobar", :attribute_2 => "foobar")
That return this :
ArgumentError: wrong number of arguments (1 for 0)
from (irb):5:in `initialize'
from (irb):5:in `new'
from (irb):5
my model:
class Object
extend ActiveModel::Naming
include ActiveModel::Conversion
def persisted?
false
end
attr_accessor :attribute_1, :attribute_2
I'm going to assume that you aren't really using
Object
as your class name. If that is the case, you just need to add the logic to set your attributes in your constructor:outputs:
Note that in real life you would want to check the list of attributes passed in the constructor to make sure they are valid attributes for your class.