lukas wrote:
> Hello everyone,
>
> newbie question:
>
> I have a couple of methods that interact with a remote python server
> in application.rb.
> Is there a convenient way to debug them? e.g. run them from "ruby
> script/console" - debug-console and see the return values?
>
Just set a breakpoint, run script/server -u, and play around in the
debugger.
> Example-method:
>
> def addUserToServer?(category_name, useremail_address)
That should be add_user_to_server. camelCase is considered poor style
in Ruby.
> socket = TCPSocket.open(host, port)
> cmd = "COMMAND:adduser;;CAT:" + (category_name,
You know you've got mismatched parentheses, right? And string
concatenation is more efficient with the "#{}" syntax.
> cmd += ";;EMAIL:" + useremail_address
> socket.puts(cmd)
> result = socket.rcv(1024)
> socket.close()
You don't need empty parentheses when a function doesn't take arguments.
Frankly, your code looks more like Java than Ruby.
> end
>
> I'd like to see contents of result f.ex. and then return true or false
> accordingly.
>
> Rails is version 2.2.2
>
> Any help on this or some other best practice to check those methods is
> appreciated.
Test-first development will reduce the need for debugging.
>
> Lukas
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.