Yeah, I'm a little confused about the best method to go about this as well — I guess since update_attributes is deprecated in Master we should be checking attributes via assign and the saving if successful?
So i THINK i'm in good shape! UNTIL I try to cap deploy: the connection hangs AFTER connecting successfully..?! Turned on SSH logging, and the key exchange is successful, but then the script doesn't continue. I CAN login without a password from the terminal, so I know my key is set up correctly on my deployer user.
Quick Q Ryan - the models I'm working with are connecting using has_many :through, and I'm getting issues with creating the sub-objects via the update method, here's the exception:
ActiveRecord::RecordNotFound
Couldn't find Question with ID=1 for Quiz with ID=9
For context, Quizzes have many questions through a join table.
Anyway, decent chance I'll have this fixed before anyone has a chance to reply, but seemed like something enough people might be trying to do to warrant a comment.
Basically, you need to re-run save on the parent object after update_attributes has had a chance to do it's thing, such that the object stores the newly-generated filename — assuming you're using digest-esque filenames.
So I turned off the after_update directive and run the cropper manually in the controller, so I can save it easily:
ruby
defcrop
avatar = current_profile.avatar
avatar.crop_x = params[:photo]["crop_x"]
avatar.crop_y = params[:photo]["crop_y"]
avatar.crop_h = params[:photo]["crop_h"]
avatar.crop_w = params[:photo]["crop_w"]
# Must re-save after update to ensure model refers to new version on S3
avatar.crop_avatar
avatar.save!
end
Ned — My models are set up in a nested fashion also, (Profile has_one Avatar) since I'm using a polymorphic "Photo" object in a couple different ways around the site.
Anyway, I'm running into an interesting issue where I'm successfully re-generating the new versions, but my Profile isn't picking up the updated Thumbnail — it's definitely saved on S3, so the actual cropping process is working very well.
Hrmmm, am I saving it incorrectly? Anyone run into something similar or have an idea?
Yeah, I'm a little confused about the best method to go about this as well — I guess since update_attributes is deprecated in Master we should be checking attributes via assign and the saving if successful?
So i'm having a weird issue - followed the instructions to the tee on a new EC2 instance running Ubuntu 12.04 (only wrinkle was in the rbenv install process, found a good tutorial explaining the differences here: http://www.stehem.net/2012/05/08/how-to-install-ruby-with-rbenv-on-ubuntu-12-04.html
So i THINK i'm in good shape! UNTIL I try to cap deploy: the connection hangs AFTER connecting successfully..?! Turned on SSH logging, and the key exchange is successful, but then the script doesn't continue. I CAN login without a password from the terminal, so I know my key is set up correctly on my deployer user.
It's all a little odd.
Figured it out, key was using the actual join relationship rather than the target of the join, then everything pretty much "just worked"
I won't lie though, this also helped (from a comment on the second part of the complex forms casts) : http://pastie.org/987614
Haha, I'm still having a through association issue...see below — any pointers??
Quick Q Ryan - the models I'm working with are connecting using has_many :through, and I'm getting issues with creating the sub-objects via the update method, here's the exception:
For context, Quizzes have many questions through a join table.
Anyway, decent chance I'll have this fixed before anyone has a chance to reply, but seemed like something enough people might be trying to do to warrant a comment.
Back to figuring it out.. :D
Solved.
Basically, you need to re-run save on the parent object after update_attributes has had a chance to do it's thing, such that the object stores the newly-generated filename — assuming you're using digest-esque filenames.
So I turned off the after_update directive and run the cropper manually in the controller, so I can save it easily:
Ned — My models are set up in a nested fashion also, (Profile has_one Avatar) since I'm using a polymorphic "Photo" object in a couple different ways around the site.
Anyway, I'm running into an interesting issue where I'm successfully re-generating the new versions, but my Profile isn't picking up the updated Thumbnail — it's definitely saved on S3, so the actual cropping process is working very well.
Hrmmm, am I saving it incorrectly? Anyone run into something similar or have an idea?