0
在我的控制器我有2佈局,但是當重定向後佈局不改變?我不會只是動作:不同的渲染布局在控制器中不加載porperly在軌道上
class HomeController < ApplicationController
layout :compute_layout
before_filter :collect_menu, :only => [:show_item, :location, :order_items, :new_line_items]
def index
@stores = Store.all
if !params[:store_id].blank?
@store = Store.find(params[:store_id])
menu_left_all(params[:store_id]) if [email protected]?
end
end
def show_item
@store = Store.find(params[:store_id])
item_childs(params[:id])
end
def location
@store = Store.find(params[:store_id])
end
def new_line_items
end
def create_line_items
@store = Store.find(params[:store_id])
item = Item.find(params[:id])
line_items = item.line_items.build(quantity: params[:quantity])
respond_to do |format|
if line_items.save
format.html { redirect_to stores_url, notice: 'Line Items was successfully created.' }
end
end
end
def compute_layout
if request.url.include?("new_line_items")
action_name = "application"
else
action_name = "front_layout"
end
end
end
謝謝解決我的問題 – tardjo