I am trying to create modules and classes based in the Rails lib
directory for my application to call. However, when ever I try and
output the result of a method in the class, all that is returned is a
pound sign. Does anyone have any idea why it is outputting this? I used
the module examples from the Programming Ruby book''s site , and this
code:
class TestModelController < ApplicationController
def index
require ''ScaleDemo''
validate = ScaleDemo.new
render :text => validate.to_s
# Always returns "#"
end
end
lib/ScaleDemo.rb
module MajorScales
def majorNum
@numNotes = 7 if @numNotes.nil?
@numNotes # Return 7
end
end
module PentatonicScales
def pentaNum
@numNotes = 5 if @numNotes.nil?
@numNotes # Return 5?
end
end
class ScaleDemo
include MajorScales
include PentatonicScales
def initialize
puts majorNum # Should be 7
puts pentaNum # Should be 5
end
end
ScaleDemo.new
Thanks for your help and time.
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---