Topic: Simple submission issue

This should be very basic for someone here. I am new to Ruby on Rails programming.
I'm trying to make a submission button so that people can enter information and then that information would be sent to my email address at support@glucosebuddy.com

Can anyone help me do that? You can find the page at http://beta.glucosebuddy.com/better_diabetes

Re: Simple submission issue

This is really basic stuff indeed. If you intend to go on programming Rails I'd recommend following some online tutorials (There are some really good ones in the Tutorials section of this site) or buying a few of the introductory Pragmatic Programmers books or something. Having even a limited foundation will help you a great deal, especially when things don't go exactly as planned.

With that out of the way the answer is straightforward, you already have most of what you need in the view, so to start let's set up a route that will handle the submitted data:

# in config/routes.rb
# Note you can name these whatever you like or use whichever controller and action name fits your application best.
map.submissions '/submissions', :controller => 'index', :action => 'submissions'

Then in the view you can keep your current form but replace the form tag to include the new route:
<% form_tag submissions_path do -%>
  Name: <%= text_field_tag 'name' %>
  ... etc ...
<% end -%>

Next we have to set up the controller to deliver the email, only one line needed!
# In the index_controller, or whichever controller you set up in the routes above.
def submissions
  # Notifier will be an ActionMailer model, which we'll create in the next, final step.
  Notifier.deliver_submission( params )
end

Now all we need to do is make an ActionMailer (and view) that will send the actual email, first on the commandline write:
# Again you can name the mailer whatever you like. I usually go with Notifier.
script/generate mailer notifier

You'll have a new model in app/models/notifier.rb, so edit that and set up the delivery method for "submissions" which we used in the controller above:
# in app/models/notifier.rb
def Notifier < ActionMailer::Base
  def submission formdata
    recipient    my_address@glucosebuddy.com
    sender       form@glucosebuddy.com
    subject      "New form entry at glucosebuddy.com"
    content_type "text/html"
    # This line gives us access to the form data in the mailer view we're about to create
    body         :formdata => formdata
  end
end

Ok we're almost there. Mailer and controller are set up, now we just need to create a view for the email we're sending, so go ahead and edit app/views/notifier/submission.html.erb and make it something like this:

<html>
<head><title>New form entry at glucosebuddy.com</title></head>
<body>
<h1>A new form was submitted at glucosebuddy.com</h1>
<p>These were the results:</p>

<p>
  Name:
  <%= formdata[:name] %>
</p>
<p>
  Email:
  <%= formdata[:email] %>
</p>
<p>
  Feedback:
  <br/>
  <%= formdata[:feedback] %>
</p></body>
</html>


And that's all.