Search code examples
ruby-on-railsrails-for-zombies

ruby on rails beginner: rails for zombies code sample


where does that @user in the code in check_ammo come from?
see code for "weapon" in model, controller, mailer and schema.rb

rails for zombies code


Solution

  • That code cant be right. Weaponmailer

      def low_ammo(weapon, zombie)
        attachments["weapon.jpg"] = weapon.picture_file
        mail to: zombie.email, subject: "#{weapon.name} has low ammo"
      end
    

    expects 2 parameters in controller

     WeaponMailer.low_ammo(@user).deliver 
    

    @user is not defined unless its defined in ActiveRecord::Base what is not the case i think. Its just broken code example