M
macaco
[Note: parts of this message were removed to make it a legal post.]
I'm sorry if this question seem stupid, but couldn't find it in the books.
I have this code in the models directory:
class Figure
attr_reader :xpos, :ypos
def initialize
@xpos = 0
@ypos = 0
@other = 0
@another = 0
end
def some
call_other(@xpos,@ypos)
end
def more
call_other(@other,@another)
end
def call_other(var1, var2)
max = 9
var1= rand(max)
var2=rand(max)
end
end
And have this on my controller:
def figure
fig = Figure.new
fig.some
render :text => "<h1>new values</h1>"+fig.xpos.to_s+" "+fig.ypos.to_s
end
Problem is, it always print 0 0... as if the random wouldn't work, but I
have test the random outside this method (calling it in the first method,
not the second one), but the second method is one I need cos I use it too
many times and with different instance variables
Any help?
I'm sorry if this question seem stupid, but couldn't find it in the books.
I have this code in the models directory:
class Figure
attr_reader :xpos, :ypos
def initialize
@xpos = 0
@ypos = 0
@other = 0
@another = 0
end
def some
call_other(@xpos,@ypos)
end
def more
call_other(@other,@another)
end
def call_other(var1, var2)
max = 9
var1= rand(max)
var2=rand(max)
end
end
And have this on my controller:
def figure
fig = Figure.new
fig.some
render :text => "<h1>new values</h1>"+fig.xpos.to_s+" "+fig.ypos.to_s
end
Problem is, it always print 0 0... as if the random wouldn't work, but I
have test the random outside this method (calling it in the first method,
not the second one), but the second method is one I need cos I use it too
many times and with different instance variables
Any help?