Successful 301 Error

We finally were able to get a successful 301 error in our browser. We did this by using the Rack gem.

We used Rack to build an app on Heroku that only returns a 301 status code and the we changed the code that Emerald types in to be $ Net::HTTP.get_response(URI("http://prettyp.herokuapp.com")).code


Domain Modeling

Ryan helped us figure out the relationships in our data so we can relate

If you are using ActiveRecod (which we are not right now) you would use a command like this to find the id paramter from the unique id that is generated. Adventure.find(4)

Adventures

title
id
introduction
later...(adventure array)

Objectives

title
id
learn.narrative
submit.narrative
review.narrative
expected-output
later...(objectives array)


Class constructors in Ruby

When you use new method, you get 'reference' on newly created object. The puts kernel method returns some internal ruby information about this object. If you want to get any information about state your object, you can use getter method:

class Adder
  def initialize(my_num)
    @my_num = my_num
  end
  def my_num
    @my_num
  end
end
y = Adder.new(12)
puts y.my_num  # => 12

Or you can use 'attr_reader' method that define a couple of setter and getter methods behind the scene:

class Adder
  attr_accessor :my_num

  def initialize(my_num)
    @my_num = my_num
  end
end
y = Adder.new(12)
puts y.my_num  # => 12Class constructors in Ruby

When you use new method, you get 'reference' on newly created object. puts kernel method returns some internal ruby information about this object. If you want to get any information about state your object, you can use getter method:

class Adder
  def initialize(my_num)
    @my_num = my_num
  end
  def my_num
    @my_num
  end
end
y = Adder.new(12)
puts y.my_num  # => 12

Or you can use 'attr_reader' method that define a couple of setter and getter methods behind the scene:

class Adder
  attr_accessor :my_num

      def initialize(my_num)
        @my_num = my_num
  end      
end

y = Adder.new(12) puts y.my_num # => 12

Published on