Problems with ajax in Rails 3

Dear all:
I’m new to Rails and I’ve encountered some problems with ajax in
Rails 3. My project is on a Ubuntu 10.04 LTS machine with ruby v1.8.7
and rails v3.0.0.

I’ve changed my rails.js file according to :

and also changed my javascript_include_tag to these three paths:

1.“http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
2.“http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js
3.“rails.js”

Everything works just fine except a controller with a ssh connection
behavior.

In my malfunctioned controller:

def remoteStatus
@ip = params[:server][:ip]
@sshid = params[:server][:sshid]
@sshpass = params[:server][:sshpass]
Net::SSH.start(@ip, @sshid, :password => @sshpass) do |
session.exec!(“free | awk ‘NR==2 {print rate = $3/$2*100}’”) do
|channel, stream, data|
@memusage = data
end
end
respond_to do |format|
format.js
end
end

In the remoteStatus.js.erb I have:

$(’#status_div’).append("<%[email protected]%>")

I am pretty sure that I can have the ssh connection result in variable
@memusage. But it seems that it never appends to the status_div block in
the corresponding view. I’m wondering if I am missing something
detailed. Can anyone help me here,please and thanks!

Best regards

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs