Skip to content

Instantly share code, notes, and snippets.

@codeschool-courses
Created August 31, 2011 18:42
Show Gist options
  • Save codeschool-courses/1184330 to your computer and use it in GitHub Desktop.
Save codeschool-courses/1184330 to your computer and use it in GitHub Desktop.
Rails for Zombies 2 - Challenge 3-9
class Weapon < ActiveRecord::Base
belongs_to :zombie
end
class WeaponsController < ApplicationController
def new
@zombie = Zombie.find(params[:zombie_id])
@weapon = @zombie.weapons.build
respond_to do |format|
format.html # new.html.erb
format.json { render json: @weapon }
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