diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb index 2571fcaac..755236240 100644 --- a/app/controllers/admin/ad_images_controller.rb +++ b/app/controllers/admin/ad_images_controller.rb @@ -22,8 +22,10 @@ class Admin::AdImagesController < Admin::AdBannersController end def update - @ad_image = AdImage.find(params[:id]) + @ad_banner = AdBanner.find params[:ad_banner][:id] + @ad_image = AdImage.find(params[:ad_image][:id]) @ad_image.update_attributes(params[:ad_image]) + @ad_banner.ad_images << @ad_image redirect_to admin_ad_images_path end @@ -38,10 +40,10 @@ class Admin::AdImagesController < Admin::AdBannersController end def create - # @ad_banner = AdBanner.find params[:ad_banner][:id] + @ad_banner = AdBanner.find params[:ad_banner][:id] @ad_image = AdImage.new params[:ad_image] - #@ad_image.to_save = true - #@ad_banner.ad_images << ad_image + @ad_image.to_save = true + @ad_banner.ad_images << @ad_image if @ad_image.save redirect_to admin_ad_images_path diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index a65f06af6..f28b1b90b 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -55,7 +55,7 @@
- <%= select_tag 'ad_banner[id]',options_from_collection_for_select(AdBanner.all, "id", "title",params[:ad_banner_id]) , :class=>"input-medium" %> + <%= select_tag 'ad_banner[id]',options_from_collection_for_select(AdBanner.all, "id", "title", @ad_image.ad_banner_id) , :class=>"input-medium" %>
@@ -244,6 +244,7 @@ + <%= f.hidden_field :id, :value => @ad_image.id %>
<%= f.submit t("submit"),:class=>"btn btn-primary" %> <%= f.submit t("cancel"),:class=>"btn ",:type => 'reset' %> diff --git a/app/views/admin/items/index.html.erb b/app/views/admin/items/index.html.erb index c5387e019..67b0d30be 100644 --- a/app/views/admin/items/index.html.erb +++ b/app/views/admin/items/index.html.erb @@ -1,9 +1,9 @@ <% node = Item.root %> - +<% unless node.nil? %>
    <%= render 'node_and_children', node: node %>
- +<% end %> <%= render 'layouts/delete_modal', delete_options: {remote: true} %> <%= javascript_include_tag "lib/jquery.pageslide.js" %> diff --git a/lib/tasks/site.rake b/lib/tasks/site.rake index 42aa52014..1fae7d3f8 100644 --- a/lib/tasks/site.rake +++ b/lib/tasks/site.rake @@ -27,7 +27,7 @@ namespace :site do site.design = design site.save theme = design.themes.first - home = Page.new( :design_id => design.id, :name => 'home', :is_published => true, :theme_id => theme.id ) + home = Page.new( :design_id => design.id, :name => 'home', :is_published => true, :theme_id => theme.id, :menu_enabled_for => [] ) home.title_translations = {"zh_tw"=>"首頁", "en"=>"Home"} home.save