You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bat/tests/syntax-tests/highlighted/Ruby On Rails/test.rb

23 lines
3.0 KiB
Ruby

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

class ContactsController < ApplicationController
 def new
 @contact = Contact.new
 end
 def create
 @contact = Contact.new(secure_params)
 if @contact.valid?
 UserMailer.contact_email(@contact).deliver_now
 flash[:notice] = "Message sent from #{@contact.name}."
 redirect_to root_path
 else
 render :new
 end
 end
 private
 def secure_params
 params.require(:contact).permit(:name, :email, :content)
 end
end