Let's try something, it's a wild guess but I hope it will answer your need. You can try this in a new application. Just create a user model, and seed some data, and add the gem 'jquery-rails' in your assets group. Run bundle install and restart your server.
In your assets/javascripts/application.js, ensure you have at least the following lines:
//= require jquery
//= require jquery_ujs
//= require_tree .
In your users_controller.rb, define the index method to fetch all users from the database and render index template, it's very simple you just have to do like this:
def index
@users = User.all
respond_to do |format|
format.html
format.js
end
end
Then edit your view file in views/users and be sure it's named index.html.erb. This view will be displayed when you try to access localhost:3000/users with your browser (in details: it's a GET HTML request). Inside your view you'll write HTML and embed ruby, just the same way as you usually do. For now simply create a div and your give it the id "more" and you also place a link with attribute remote
<%= link_to 'click me', users_path, remote: true %>
Then create a new view file in views/users and name it index.js.erb. You notice that the extension changed, now we use js.erb instead of html.erb. In detail: when your page will do a javascript request (a GET JS in this case) to your users#index route, it will answer with the index.js.erb view. The big nice stuff here is you can write javascript code in this view that will get executed in your browser.
You remember we added remote: true to the link? This tells rails to general a link that will make a JS request. Magic.
So now you just have to write some javascript code in your views/users/index.js.erb file. Let's start with something super simple:
alert('Hello');
Go to your page (normally localhost:3000/users) and click the 'click me' link, you should see the javascript alert box displaying.
Let's do a second test, and integrate some ruby code. Change the content of your your views/users/index.js.erb by this :
alert('Ruby compute: <%= 1+1 %>');
And in your web page, you'll see the alert with the test 'Ruby compute: 2'. You just have to adapt this technique to your case in your application et voila.
The same technique (but with better explanation) can be found on this railscast: http://railscasts.com/episodes/136-jquery
.erbextension.