From ddf7931123b2b0fe69ba473b5932c2432c19a690 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Wed, 25 Apr 2012 11:38:45 +0800 Subject: [PATCH] Change ad_banner preview from using title to id --- app/assets/javascripts/inc/modal-preview.js | 2 -- .../admin/ad_banners_controller.rb | 4 +-- .../admin/ad_banners/_ad_banner_tab.html.erb | 2 +- .../admin/ad_banners/_modal_preview.html.erb | 36 ++++++++++--------- config/routes.rb | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/app/assets/javascripts/inc/modal-preview.js b/app/assets/javascripts/inc/modal-preview.js index 35195999..44fa62a3 100644 --- a/app/assets/javascripts/inc/modal-preview.js +++ b/app/assets/javascripts/inc/modal-preview.js @@ -7,9 +7,7 @@ $(document).ready(function() { $(this).after(""); $.ajax({ type: 'PUT', - //async : true, url:$(this).attr("href"), - contentType: 'application/javascript; charset=utf-8', data:$(this).parents("form").serialize(), success: function (msg) { $("#"+start_modal_with_id).modal('show'); }, diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index 1e96907f..a21693aa 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -45,8 +45,8 @@ class Admin::AdBannersController < ApplicationController end def realtime_preview - @ad_banner = AdBanner.first(conditions: { title: params[:title] }).preview_clone - #@ad_banner.update_attributes(params[:ad_banner]).update_attributes(params[:ad_images]) + @ad_banner = AdBanner.find( params[:id] ).preview_clone + @ad_banner.update_attributes(params[:ad_banner])#.update_attributes(params[:ad_images]) end def index diff --git a/app/views/admin/ad_banners/_ad_banner_tab.html.erb b/app/views/admin/ad_banners/_ad_banner_tab.html.erb index c1e406db..79dc647c 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -11,7 +11,7 @@
<%= link_to t("admin.ad.new_image"),new_admin_ad_banner_ad_image_path(ad_banner_tab) ,:class => "btn btn-primary"%> - <%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(ad_banner_tab.title) , :class=>'preview_trigger btn btn-success'%> + <%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger btn btn-success'%>