Fix relation for Ad_banner and Ad_image

Update site.rake for New UI
This commit is contained in:
Manson Wang 2013-10-04 19:17:45 +08:00
parent 43cf6b70b7
commit 792785f7ba
4 changed files with 11 additions and 8 deletions

View File

@ -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

View File

@ -55,7 +55,7 @@
<div class="control-group">
<label class="control-label muted">Banner</label>
<div class="controls">
<%= 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" %>
</div>
</div>
@ -244,6 +244,7 @@
</div>
<!-- Form Actions -->
<%= f.hidden_field :id, :value => @ad_image.id %>
<div class="form-actions">
<%= f.submit t("submit"),:class=>"btn btn-primary" %>
<%= f.submit t("cancel"),:class=>"btn ",:type => 'reset' %>

View File

@ -1,9 +1,9 @@
<% node = Item.root %>
<% unless node.nil? %>
<ol id='<%= node.id %>' class="sortable item-groups">
<%= render 'node_and_children', node: node %>
</ol>
<% end %>
<%= render 'layouts/delete_modal', delete_options: {remote: true} %>
<%= javascript_include_tag "lib/jquery.pageslide.js" %>

View File

@ -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