Forum: Rails I18n How to refresh Image through ajax request

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Kumar S. (Guest)
on 2009-01-16 17:34
Hi all ,
I am very new for ruby. I am using Ajax Request(Rmagick in controller)
for changing image on my DIV but the problem is it refresh for first
time only then after i have to refresh the browser always. If anybody
having any solution, Please let me know . I am posting my code here

Code in rhtml file
==================================================================================
<%= form_remote_tag({:url=>{:controller=>'image_builders', :action
=>'index'}, :update =>'photo'})%>
        <dl style="width:450px">
          <dt>Type</dt>
<!--  form element -->


</dl>
          <%= submit_tag 'Create Image' %>
        </div>

<!--  End of form -->
<!--  Preview Area  -->
<div>
          <label><b>Image:</b></label>

          <div id="photo" style="width:99%;">

          </div>
          </div>

<!--  End of Preview Area -->

===============================================================================
code in controller

 def index
    @Rows =20
    @Cols = 120
    @alpha = params[:alpha].to_i
    @margin = params[:margin].to_i
    if params[:height].to_i >9000 ||  params[:width].to_i  > 9000
      if params[:height].to_i >9000
        params[:height] = 8999
      end
      if params[:width].to_i  > 9000
        params[:width] = 8999
      end
    end
    if params[:height] && params[:width]
      @Rows =params[:height].to_i
      @Cols = params[:width].to_i
    end
      @Start = params[:input_field_1]
      @End = params[:input_field_2]
    if params[:type] == 'gradation'
      fill = Magick::GradientFill.new(0, 0, 0, @Cols, @Start, @End)
      img = Magick::Image.new(@Rows, @Cols, fill)
       img.opacity = @alpha/ 127.0 * Magick::TransparentOpacity if
@alpha != 0
      img_new = img.rotate(90)
      if params[:reverse]
        img_rev = img_new.rotate(270)
        img_rev.write("public/images/xyz.jpg")
        render :text => "<img src='/images/xyz.jpg' />"
      else
        img_new.write("public/images/xyz.jpg")
        render :text => "<img src='/images/xyz.jpg' />"
      end
    end
end
================================================================================

Thanks in Advance
This topic is locked and can not be replied to.