Forum: Ruby on Rails Send link_to in JSON

E97b71568ca59110b4fa1ce4d32cbbc2?d=identicon&s=25 Kristers Zarins (kristers_z)
on 2013-10-30 22:13
In my View I have a list of items in database. By the side of each item
in there is "delete" link.
There is also an AJAX form which allows to create new items. New items
are appended to list by JS.

When submit button is pressed, controller should send back JSON. The
problem is - how to send that "delete" link as a JSON? Since link's html
has some double quotes in it, I dont get valid JSON and my JS crashes.

destroy_link  = view_context.link_to('Delete', created, method: :delete,
remote: true, :class => 'minus' )

json = {'plural'       =>,
  'singular'     =>,
  'created'      => created

Since I dont know a lot about ajax, propably something is terribly wrong
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.