1

I am working in rails 2. I want to make an link_to_remote object and render it on html page. I want to send date via ajax. I am trying this.

render :text => "<font color='"+ color +"'>" +params[:ajax_status] + "</font>" + <%= link_to_remote '| Undo',
              :update => 'status_'" +params[:ajax_status]+ ",:url => {:controller => 'requests', :action => 'action_on_punching_request', :id => "+ params[:id] +" :ajax_status => 'Undo'} %>

But unable to proceed. It shows on webpage

Accepted<%= link_to_remote '| Undo', :update => 'status_'Accepted,:url => {:controller => 'requests', :action => 'action_on_punching_request', :id => 20 :ajax_status => 'Undo'} %>

PLease help me out.

Bilal Ahmed
  • 423
  • 1
  • 6
  • 11
  • i think u r concatinating the link code to a string and hence its getting displayed on view. – Prasad Surase Oct 10 '12 at 05:24
  • u may also have a look at http://stackoverflow.com/questions/5511787/rails-2-to-rails-3-using-link-to-instead-of-link-to-remote-including-remote-a – Prasad Surase Oct 10 '12 at 05:25
  • Check out the API documentation for [link_to_remote](http://apidock.com/rails/ActionView/Helpers/PrototypeHelper/link_to_remote). – icantbecool Oct 10 '12 at 05:39

1 Answers1

1

You don't need the <%= %> tags, in this case - they're for erb.

Try just:

render :text => "#{ content_tag :font, params[:ajax_status], :color => color }#{  link_to_remote '| Undo', :update => "status_#{ params[:ajax_status] }", :url => {:controller => 'requests', :action => 'action_on_punching_request', :id => params[:id], :ajax_status => 'Undo'}  }"
Brad Werth
  • 17,411
  • 10
  • 63
  • 88