Skip to content

Instantly share code, notes, and snippets.

@codeschool-courses
Created August 31, 2011 18:34
Show Gist options
  • Save codeschool-courses/1184306 to your computer and use it in GitHub Desktop.
Save codeschool-courses/1184306 to your computer and use it in GitHub Desktop.
Rails for Zombies 2 - Challenge 3-8, 3-12
class Weapon < ActiveRecord::Base
belongs_to :zombie
end
class WeaponsController < ApplicationController
def index
@zombie = Zombie.find(params[:zombie_id])
@weapons = @zombie.weapons
respond_to do |format|
format.html # index.html.erb
format.json { render json: @weapons }
end
end
end
class Zombie < ActiveRecord::Base
has_many :weapons
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment