You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey guys, I am quite new to programming and I can't call a certain method in file from a different file.
I am using Sinatra and I am trying to display some input to a browser. According to my practical sheets from uni this is supposed to display the number from source file to the browser. It works for the command line window but not when I am calling it from the layout.rb file. It is giving me uninitialized constant error. Please Help!
mainfile.rb
require "#{File.dirname(FILE)}/source"
require 'sinatra'
get '/' do
home :erb
end
source.rb
module OXO_Game
class Game
attr_reader :input, :output
attr_writer :input, :output
def initialize(input, output) @input = input @output = output
end
def student_id
@student_id = "51235134"
end
end
end
Hey guys, I am quite new to programming and I can't call a certain method in file from a different file.
I am using Sinatra and I am trying to display some input to a browser. According to my practical sheets from uni this is supposed to display the number from source file to the browser. It works for the command line window but not when I am calling it from the layout.rb file. It is giving me uninitialized constant error. Please Help!
mainfile.rb
require "#{File.dirname(FILE)}/source"
require 'sinatra'
get '/' do
home :erb
end
source.rb
module OXO_Game
class Game
attr_reader :input, :output
attr_writer :input, :output
def initialize(input, output)
@input = input
@output = output
end
def student_id
@student_id = "51235134"
end
end
end
layout.rb
<% require "#{File.dirname(__FILE__)}/source" %><%= yield %>
The text was updated successfully, but these errors were encountered: