Dear all

In the MVC architecture framework, the Model is actually communicate
with database. In my rails project, there is a model/ssh.rb that is not
connect with database. Is it a good practice for this arrangement in my
project? Am I violate the rules of MVC architecture? Or is it better to
move all the codes from models to controllers? What do you think? Thank
you.

models/ssh.rb
$LOADED_FEATURES[$LOADED_FEATURES.length] =
'net/ssh/authentication/pageant.rb'
require 'net/ssh'

class Ssh

  def self.execute(cmd)
    ssh=Net::SSH.start("ahnibm71", "testlib", :port => 19207, :paranoid
=> false, :auth_methods => ["publickey"], :passphrase => "hellokitty",
:keys => ["C:/testing/id_rsa"])
    output = ssh.exec!(cmd)
    ssh.close
    if output.nil?
      return "NULL"
    else
      return output.gsub("\n", "<br>")
    end
  end

end

controllers/ssh_controller.rb
class SshController < ApplicationController
  def main
  end

  def test
    render :text => Ssh.execute(params[:command])
  end

end
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to