2

In my Rails 3 application I have a typical 'Email this to a friend' form that has yours/friend's email and name fields. Each of them must be validated and error messages must be displayed, in a fashion similar to ActiveRecord forms:

  <%= form_tag %>
    <div class="fields">
      <%= label_tag :friends_name %>
      <%= text_field_tag :friends_name, params[:friends_name] %>
      <%= label_tag :friends_email %>
      <%= text_field_tag :friends_email, params[:friends_email] %>
    </div>
    <div class="fields">
      <%= label_tag :your_name %>
      <%= text_field_tag :your_name, params[:your_name] %>
      <%= label_tag :your_email %>
      <%= text_field_tag :your_email, params[:your_email] %>
    </div>
    <div class="fields">
      <%= label_tag :message %>
      <%= text_area_tag :message, params[:message] %>
    </div>
    <%= submit_tag 'Send'%>
  </form>

What would be the 'Rails way' of doing this?

1 Answer 1

1

I found the answer in the episode #219 - Active Model on railscasts.com

Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.