ruby on rails - How to add a title when you don't know what you're asking for? -


i don't know how ask i'm asking ... i'd google if knew looking for!

so, have set of carrierwave versions of images names image00, image01, image02 etc image25 stored as:

@photo.main.image00, @photo.main.image01 etc ...

i want able use controller post these images out. have no idea how string request together. i've got objective-c, javascript, ruby , host of other languages fighting space in head, , ruby seems have lost out!

i wish able make call such as:

@photopiece = base64.strict_encode64(file.read(@photos.main.imagexx.current_path)) 

but have no idea how replace xx digit , still have file encoded.

i tried:

imagestring = "@photos.main.image#{sendpiece}.current_path" 

and then

@photopiece = base64.strict_encode(file.read(imagestring)) 

but did nothing ... hear compiler laughing @ me (such paranoia now!)

so, how photo names appear in form:

@photos.main.imagexx.current_path 

such can parsed strict_encode?

thanks in advance help! , reading ramblings ...

ps. apologies bad heading! please change if know i'm asking for!

maybe, more secure silly eval(params..):

 number_is_safe = !!float(sendpiece) rescue false  if number_is_safe    path = eval "@photos.main.image#{sendpiece}.current_path"    @photopiece = base64.strict_encode(file.read(path))  end 

jvnill propose better solution:

piece = @photos.main.public_send("image#{sendpiece}") @photopiece = base64.strict_encode64(file.read(piece.current_path)) 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -