Hi all, Looking for best practices when it comes to submitting a form
and canceling a form in Rails.
Background:
I am leveraging a CSS dynamic that gives hover over and an embedded Icon
to all buttons in my application so most buttons are anchors in my
application. Artclie on the implementation:
Looking for advise on this:
In order to keep these nice looking buttons I have to submit the form
with an anchor and cancel with an anchor tag. Is it okay to have the
cancel button just leave the page and go to a path or should I direct it
to the controller and then go to the Path ? What is the best practice?
Am I missing some kind of clean up I should be doing or is leaving the
page acceptable ?
Code:
%div
-
form_for @activity, :url => { :action => “update” }, :html => {:id
=>“aform”} do |f|
= f.error_messages
%p
= f.label :title
%br
= f.text_field :title
%p
= f.label :artifact
%br
= f.select(:artifact, %w{HLD SRS IA})
%p
= f.label :milestones
%br
= f.select(:milestone, %w{M5 M4 M3})%div
%span.buttons
%a{:href => “javascript:{}”, :onclick =>
“document.getElementById(‘aform’).submit(); return false;”}
%img{:src =>“/images/img/icon-check.png”, :border => “0”}
submit
%span.buttons
= link_to image_tag(“/images/img/icon-delete.png”,
:border=>0)+“Cancel”, activity_path