validates image and also remove height and width validations

This commit is contained in:
Harry Bomrah 2015-11-18 17:04:16 +08:00
parent 4c1a1ec02f
commit 4ed005b063
2 changed files with 13 additions and 3 deletions

View File

@ -6,7 +6,7 @@ class Banner
field :ad_fx, type: String
field :height, type: Integer
field :speed, type: Integer
field :speed, type: Integer, default: 500
field :title, type: String
field :timeout, type: Integer, default: 5
field :width, type: Integer
@ -16,7 +16,6 @@ class Banner
validates_uniqueness_of :title
validates :title, :length => { :minimum => 2 }
validates :height, :speed, :timeout, :width, :presence => true
FX_TYPES = %w(fade scrollHorz scrollVert tileSlide tileBlind)

View File

@ -7,6 +7,7 @@
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/module-area" %>
<%= javascript_include_tag "validator" %>
<% end %>
<%#= f.error_messages %>
@ -38,7 +39,7 @@
<span class="btn btn-file">
<span class="fileupload-new"><%= t(:select_image) %></span>
<span class="fileupload-exists"><%= t(:change) %></span>
<%= f.file_field :file %>
<%= f.file_field :file, :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty.;"}%>
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
<div class="controls" data-toggle="buttons-checkbox">
@ -149,3 +150,13 @@
<input type="hidden" name="referer_url" value="<%= request.referer %>">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
</div>
<script type="text/javascript">
var form = new FormValidator($("#new_ad_image"));
</script>