I’m building a rails app where a user can type in six words about themselves and upload an image. I want to append those six words to the image.
I know how to get text append to work using “static” text, but I don’t know how to link the text field to the form the users fill out when they type in their six words.
Right now, ‘Text’ is static and whatever I put.
I wonder why the following doesn’t work?
process :textify => <%= @user.sixwords %>
Here is what I have:
process :textify => 'Text'
def textify(phrase)
manipulate! do |img|
img = img.sepiatone
title = Magick::Draw.new
title.annotate(img, 0,0,0,40, phrase) {
self.font_family = 'Helvetica'
self.fill = 'white'
self.pointsize = 32
}
img = img.write('newimg.gif')
end
end
Thanks for helping me become a little less of a n00b! 🙂
Figured it out with the help of a friend.
This is all that I needed to change:
This works because Carrierwave uses
modelas the variable that points to whatever instance object the uploader is attached to. In my model,namewas the name of the form field that took the user text input.For other use cases you’d just take
model.field_namewhere you put whatever name you give to yourfield_name.My friend wrote it like this to explain it to me. I’m pasting it here in case it can help others.