Created
January 4, 2012 12:11
-
-
Save Znow/1559785 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Contact Mailer | |
class Contact < ActionMailer::Base | |
#default :to => "[email protected]" | |
def contact(message) | |
@message = message | |
@sender = @message.email | |
mail( | |
:from => @sender, | |
:to => "[email protected]", | |
:subject => "[Contact AC]" | |
) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ContactController < ApplicationController | |
def new | |
@message = Message.new | |
end | |
def create | |
@message = Message.new(params[:message]) | |
@message = Message.new(params[:message]) | |
@message.request = request | |
if @message.deliver | |
# if @message.valid? | |
# NotificationsMailer.new_message(@message).deliver | |
redirect_to root_path, :notice => "Din email blev sendt, vi kontakter dig." | |
else | |
render :new, :error => "Din email blev ikke sendt." | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%h3 Din email blev sendt, vi kontakter dig. | |
%p | |
We'll get back to you as soon as possible. | |
%p | |
= link_to 'Home', root_url, :class => 'button' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Message | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
extend ActiveModel::Naming | |
email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i # full regex | |
attr_accessor :id, :name, :email, :message | |
validates :name, :presence => true, :length => { :minimum => 2 } | |
validates :email, :presence => true, :format => { :with => email_regex } | |
validates :message, :presence => true, :length => { :minimum => 2 } | |
def initialize(attributes = {}) | |
attributes.each do |key, value| | |
send("#{key}=", value) | |
end | |
end | |
def persisted? | |
false | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%div{:style => "clear:both;float:right;margin-right:250px;"} | |
%h3 Vores beliggenhed | |
#map{:style => "clear:both;float:right;width:400px;height:300px;margin-right: 10px;"} | |
%h3 Kontakt os | |
= form_for @message, :url => contact_path do |f| | |
- unless @message.errors.empty? | |
#error_explanation | |
Please correct the following: | |
%ul | |
- @message.errors.full_messages.each do |err| | |
%li | |
%strong= err | |
.field | |
= f.label :name, "Navn" | |
%br/ | |
= f.text_field :name | |
.field | |
= f.label :email, "Email" | |
%br/ | |
= f.text_field :email | |
.field | |
= f.label :message, "Besked" | |
%br/ | |
= f.text_area :message | |
.action | |
= f.submit "Send" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Notifications Mailer | |
class NotificationsMailer < ActionMailer::Base | |
#default :to => "znowm" | |
#default :from => | |
def new_message(message) | |
@message = message | |
mail( | |
:from => @message.email, | |
:to => "[email protected]", | |
:subject => "[Contact AC]" | |
) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Advicecapital::Application.routes.draw do | |
#match '/contact' => 'contact#new', :as => 'contact', :via => :get | |
#match '/contact' => 'contact#create', :as => 'contact', :via => :post | |
devise_for :users | |
resources :news | |
resources :boards | |
resources :contacts | |
resources :videos | |
resources :employees | |
namespace :admin do | |
root :to => 'dashboard#index' | |
resources :advice_pages | |
resources :boxes, :only => [:index, :show, :edit, :update] | |
resources :investors | |
resources :stocks | |
resources :users | |
end | |
root :to => "pages#index" | |
match '/receive_news', :to => 'pages#receive_news' | |
match '/disclaimer', :to => 'pages#disclaimer' | |
match '/organisation', :to => 'employees#index' | |
mount Resque::Server, :at => "/resque" | |
match '/*slugs', :to => 'pages#show' | |
# AdvicePage.all.each do |r| | |
# match r.slug, :to => "pages#show" | |
# end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment