Is "send" method not allowed?

Hi,
When I define a “send” method in my Organise::MessageController class,
and
try to open the url http://127.0.0.1:3000/organise/message, I get an
error
saying “We’re sorry, but something went wrong”!, and when I remove this
method, everything seems to work fine.
Please, let me know why this happening.
-thanks


-nasa
http://vikrant.co.in

Vikrant C. wrote:

Hi,
When I define a “send” method in my Organise::MessageController class, and
try to open the url http://127.0.0.1:3000/organise/message, I get an error
saying “We’re sorry, but something went wrong”!, and when I remove this
method, everything seems to work fine.
Please, let me know why this happening.
-thanks

What does the error message in your log file say?


Michael W.

Here is the complete log message -

Processing MessageController#index (for 127.0.0.1 at 2007-10-07
09:48:15)
[GET]
Session ID: 663defd9462d72e29f440f9d50298ba6
Parameters: {“action”=>“index”, “controller”=>“organise/message”}

Processing MessageController#index (for 127.0.0.1 at 2007-10-07
09:48:15)
[GET]
Session ID: 663defd9462d72e29f440f9d50298ba6
Parameters: {“action”=>“index”, “controller”=>“organise/message”}
wrong number of arguments (1 for 0)

C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in
`send’

C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in
`process_without_filters’

C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in
`process_without_session_management_support’

C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in
`process’

C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in
`process’

C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in
`dispatch’

C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:113:in
`handle_dispatch’

C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:79:in
`service’

C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service’

C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run’

C:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread’

C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start’

C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread’

C:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start’

C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each’

C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start’

C:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start’

C:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start’

C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:63:in
`dispatch’

C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3
/lib/commands/servers/webrick.rb:59

C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require’

C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require’

C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require’

C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
`new_constants_in’

C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
`require’

C:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39

C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require’

C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require’

script/server:3

2007/10/7, Michael W. [email protected]:

Please, let me know why this happening.


-nasa
http://vikrant.co.in

Actually, send is reserved in Ruby, not just rails as it’s a method
defined in Object:

http://corelib.rubyonrails.org/classes/Object.html#M001077

hrm…

irb(main):001:0> class Hacked
irb(main):002:1> def send
irb(main):003:2> “bwahaha I h4x0r3ed j00r s3nd!! pwnz0r”
irb(main):004:2> end
irb(main):005:1> end
=> nil
irb(main):006:0> Hacked.new.send
=> “bwahaha I h4x0r3ed j00r s3nd!! pwnz0r”

Ruby actually provides a send method, simply because sometimes you
DO want to write your own method named #send. So, send isn’t really a
protected method at all.

Neither is any other method on Object, for that matter, afaik.
They’re just methods, so you can do whatever you want to them.

Pat

meh, by protected I meant reserved, hope it’s obvious

send is a reserved word in rails because it uses send() a lot in the
framework code to call methods dynamically. Rename your send method
to send_message or anythign besides send and you will be fine.

Cheers-
-Ezra

Quite true, and should have been obvious from the start. Thanks for
pointing that out.

On Oct 6, 2007, at 9:30 PM, William P. wrote:

Actually, send is reserved in Ruby, not just rails as it’s a method
defined in Object:

http://corelib.rubyonrails.org/classes/Object.html#M001077

It’s not exactly reserved as you can redefine it, but if you are
running code that depends on using send to call methods(like rails)
then redefining it is a bad idea.

Cheers-
– Ezra

Well, now I know the reason! Thanks to you all. ( 8 answers just in 30
minutes! Its amazing! rails community is really helpful. Thanks
again.)

On 10/7/07, Jeremy K. [email protected] wrote:

On 10/6/07, Ezra Z. [email protected] wrote:

    It's not exactly reserved as you can redefine it, but if you are

running code that depends on using send to call methods(like rails)
then redefining it is a bad idea.

That’s what ‘reserved’ means.

You can define your own send, object_id, or class methods also – boom.

On the other had send IS usurped even in the Ruby standard library:

$ qri send
------------------------------------------------------ Multiple choices:

 Object#send, Resolv::DNS::Requester::ConnectedUDP::Sender#send,
 Resolv::DNS::Requester::TCP::Sender#send,
 Resolv::DNS::Requester::UnconnectedUDP::Sender#send,
 SOAP::HTTPStreamHandler#send, UDPSocket#send


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

On 10/6/07, Ezra Z. [email protected] wrote:

    It's not exactly reserved as you can redefine it, but if you are

running code that depends on using send to call methods(like rails)
then redefining it is a bad idea.

That’s what ‘reserved’ means.

You can define your own send, object_id, or class methods also –
boom.

jeremy

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