I'm trying to write code that will let me search the content submitted through a form and find the email address in the content. Below is the code, and the error message I'm receiving.
Error: undefined method `match' for {"content"=>"this is a test testemail@gmail.com"}:ActionController::Parameters
Code:
class ChallengesController < ApplicationController
def create
@challenge = current_user.challenges.build(challenge_params)
challenge_params.match(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i)
# ...
end
private
def challenge_params
params.require(:challenge).permit(:content)
end
end