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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 17 Jan 2009, at 07:33, Kumar Saurav wrote:> > 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 >Is it your browser caching the image? Fred> 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 > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---