Class: UserQueriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/user_queries_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#block_api_access, #clean_params_from_check, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!

Instance Method Details

#createObject


6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/user_queries_controller.rb', line 6

def create
  @user_query = UserQuery.new(user_query_params.merge(user: current_user))
  if @user_query.valid?
    UserQueryMailer.request_for_help(@user_query).deliver_now
    flash[:notice] = "Thank you for your request. We will contact you shortly (via #{@user_query.user_email})"
    redirect_to new_user_query_path
  else
    flash.now[:error] = @user_query.errors.full_messages
    render :new
  end
end

#newObject


2
3
4
# File 'app/controllers/user_queries_controller.rb', line 2

def new
  @user_query = UserQuery.new(url: request.referer, user: current_user)
end

#user_query_paramsObject


18
19
20
# File 'app/controllers/user_queries_controller.rb', line 18

def user_query_params
  params.require(:user_query).permit(:user_email, :url, :what_was_trying_to_do, :what_happened, :what_expected)
end