In my Rails 3.2 project, I have a form to create a new post in new.html.erb in app/views/posts/
<%= form_for(@post) do |post_form| %>
...
<div class="field">
<%= post_form.label :email %><br />
<%= post_form.text_field :email %>
</div>
<div class="field">
<%= post_form.label :title %><br />
<%= post_form.text_field :title %>
</div>
<div class="field">
<%= post_form.label :content %><br />
<%= post_form.text_field :content %>
</div>
<div class="actions">
<%= post_form.submit %>
</div>
<% end %>
Then the create function in posts_controller.rb
def create
@post = Post.new(params[:post])
if @post.save
format.html { redirect_to @post }
else
format.html { render action: "new" }
end
end
When the user submits a post, I want to send an email notification to email that "You have submitted a post with title title and content content." How can I do that?