You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Channel.blueprint do
name
short_name
description
end
Post.blueprint do
channel
title
body
end
Attachment.blueprint do
post
end
This works fine except in calling Attachment.make. I consistently receive the following error:
ArgumentError in 'Attachment should belong to post'
wrong number of arguments (0 for 1)
/Users/jakepaul/Projects/chirp/spec/blueprint.rb:26:in `post'
/Users/jakepaul/Projects/chirp/spec/blueprint.rb:26:
/Users/jakepaul/Projects/chirp/vendor/plugins/machinist/lib/machinist.rb:20:in `instance_eval'
/Users/jakepaul/Projects/chirp/vendor/plugins/machinist/lib/machinist.rb:20:in `run'
/Users/jakepaul/Projects/chirp/vendor/plugins/machinist/lib/machinist/active_record.rb:52:in `make'
./spec/models/attachment_spec.rb:7:
I've been troubleshooting for awhile and I think it must have something to do with the way the instance_eval works. Replacing post in the Attachment.blueprint block with post_id {2} causes it to work, and I can call Attachment.make{:post => post} successfully in the spec.
If I replace the has_many/belongs_to relationship between Post and Attachment with one between Channel and Attachment (so attachments belong to a Channel instead of a Post), the relationship works as expected. This leads me to suspect that there may be a problem with nesting the relationship (Attachment belonging to Post belonging to Channel) and possibly with instance_eval, but I'm not experienced enough with instance_eval to know why or how to fix it.
Thank you in advance!
The text was updated successfully, but these errors were encountered:
Update: Running script/console in the test env and then requiring spec/blueprint, this problem does not seem to occur. Attachment.make works and it creates a post properly (and the post has an associated channel). Any idea what might be causing this?
I figured it out. I was including ActionController::TestProcess in order to use fixture_file_upload, but that also included a method named post. So it thought I was trying to call the method.
I had guessed that it might be something like that but I was not making the connection to ActionController::TestProcess. Thank you very much, though! I really like machinist.
I have blueprints.rb set up like this:
This works fine except in calling Attachment.make. I consistently receive the following error:
I've been troubleshooting for awhile and I think it must have something to do with the way the instance_eval works. Replacing post in the Attachment.blueprint block with post_id {2} causes it to work, and I can call Attachment.make{:post => post} successfully in the spec.
If I replace the has_many/belongs_to relationship between Post and Attachment with one between Channel and Attachment (so attachments belong to a Channel instead of a Post), the relationship works as expected. This leads me to suspect that there may be a problem with nesting the relationship (Attachment belonging to Post belonging to Channel) and possibly with instance_eval, but I'm not experienced enough with instance_eval to know why or how to fix it.
Thank you in advance!
The text was updated successfully, but these errors were encountered: