Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined method `remote_function'

I am using rails-3.2.1 with blacklight application

I am trying to invoke remote_function in my link_to tag.

<%= link_to_document document, :label=>document_show_link_field, :onclick =>     remote_function(:controller => 'catalog', :action => 'save_user_history') %>

This gives following error

undefined method `remote_function' for #<#<Class:0x2ff0dc0>:0x2f4af38>.

Does anyone know why?

like image 520
shaz404 Avatar asked Jun 06 '12 11:06

shaz404


2 Answers

This function was part of the Prototype helper which was removed from the framework with Rails 3.1 and moved to the prototype-rails gem.

like image 103
Peter Brown Avatar answered Oct 20 '22 17:10

Peter Brown


You can always use a normal link_to.

<%= link_to "Save User History", save_user_history_catalogs_path %>

Or if it is a ajax function, something like this:

<a id="save_user_history">Save User History</a>

And in your javascript file:

$("#save_user_history").click(function() {
  $.post("/catalogs/save_user_history", function(data) {
    ....
like image 22
MurifoX Avatar answered Oct 20 '22 18:10

MurifoX