Thursday, 15 April 2010

html - Upload Image not using erb (form) rails -



html - Upload Image not using erb (form) rails -

i wondering if there way upload images in rails 4 not using erb. have html code in quotations in model (so can utilize default when creating page). cant set erb in quotes, cuz if it'll come out erb code , not actual view. (i.e. upload image form. itll come out actual f.image_tag instead of actual upload button).

so seeing if there way implement image uploading quotations wont require erb. but, uses rails 4.

if have plain html code within string, , want displayed, need phone call .html_safe in view, like:

'<div id="foo">bar</div>'.html_safe()

note bad practice: doesn't mean bad, means attending point create sure best way it.

if want image upload without using form.image_tag, can set in view , see generated code (ctrl+u in chrome), that, in case, like:

<input type="file" id="something" />

and add together string. finer validation , options added via js, pain add together way - 1 way to add together script tag html code.

if, however, string contains code this, , asking way not working, need add together eval caller, e.g.:

eval('form.image_tag :image')

not worse smell, , should avoided @ costs.

maybe improve add together flags in section.rb model, , utilize in helper or in view render html; example, has_upload? field, , can this:

if @section.has_upload? form.image_tag :imagem end

html ruby-on-rails ruby

No comments:

Post a Comment