Skip to content

Instantly share code, notes, and snippets.

@jplong91
jplong91 / bowling_game_problem.rb
Last active September 21, 2022 18:01
Score a Bowling Game
# Credit to Joe Mastey for most of the contents of this file.
# The rules listed here operate just as a game of bowling would.
# Solve one problem at a time, in order.
# Make sure to re-run any previously solved examples.
# Sometimes code changes that work towards the current example will break a prior one
# In general, you should solve each problem using whatever means necessary to get working code.
# At some point you may cross a bridge where your logic is quite tangled.
# Empower yourself to refactor towards an understandable solution, or think about new ways to approach scoring a bowling game.
class John
def build(input_num)
input_num + 1
end
def destroy(input_num)
input_num - 1
end
end
@jplong91
jplong91 / til.md
Last active April 24, 2021 22:04
Today I Learned...

TIL - Today I Learned

Wednesday, 11/20/19

Explaining require and permit: params.require(:person).permit(:name, :age)

The params in a controller looks like a Hash, but it's actually an instance of ActionController::Parameters, which provides several methods such as require and permit.

The require method ensures that a specific parameter is present, and if it's not provided, the require method throws an error. It returns an instance of ActionController::Parameters for the key passed into require.