ref: master
app/controllers/public/contact_controller.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
class ContactController < PublicController needs_profile before_filter :allow_access_to_page def new @contact = build_contact if request.post? && params[:confirm] == 'true' @contact.city = (!params[:city].blank? && City.exists?(:id => params[:city])) ? City.find(params[:city]).name : nil @contact.state = (!params[:state].blank? && State.exists?(:id => params[:state])) ? State.find(params[:state]).name : nil if @contact.deliver session[:notice] = _('Contact successfully sent') redirect_to :action => 'new' else session[:notice] = _('Contact not sent') end end end protected def build_contact params[:contact] ||= {} if logged_in? user.build_contact profile, params[:contact] else Contact.new params[:contact].merge(dest: profile) end end end |