Forum: Ruby on Rails Run method at the same class

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Steve (Guest)
on 2006-01-17 01:59
Sory for dummy question and bad english )

i've got a controller class

class ArtController < ApplicationController
	layout "main"
	scaffold :art

      def rec

		a = a + 'hellomoto'
	end
	def srec
		for i in 0...5
			# run rec here  (<- i dont know how do it )
		end


	end
end

at the srec method i what run rec method at while. how i can do it?)
whats syntax?
thanks
Jens-Christian F. (Guest)
on 2006-01-17 12:30
(Received via mailing list)
> 		for i in 0...5
> 			# run rec here  (<- i dont know how do it )
> 		end
>
>
> 	end
> end
>

Just use ....

	5.times do
	   rec
         end

Or
     	   self.rec

Myself, I like the second form better (self.rec), because it tells
the reader, what object you are using

cu jc
This topic is locked and can not be replied to.