在我的項目中,我有一個地方,閃光燈數據消失。 我控制器(無關緊要的代碼已被刪除):奇怪的閃光行爲
class PlacementController < InheritedResources::Base
defaults resource_class: Reservation, collection_name: 'reservations', instance_name: 'reservation'
before_filter :check_user_buildings
def show
end
def update
flash[:notice] = "1"
redirect_to placement_path(type: "entry")
end
protected
def check_user_buildings
if current_user.building_ids.empty?
redirect_to :back, alert: t("layout.placement.no_building")
end
end
end
我show.htm.haml
觀點:
= render :partial => 'layouts/flash', :locals => {:flash => flash}
= link_to t("layout.placement.populate"), "#", class: "btn btn-success placement-link pull-right"
= form_tag placement_path, method: :put, id: "placement_form" do
= "ttt"
路線佈局:
resource :placement, :controller => 'Placement'
和我的JS:
$(function(){
$('.placement-link').on('click', function(){
$("#placement_form").submit();
});
})
因此,當我點擊放置鏈接時,它重定向到我的視圖,但沒有閃光。很奇怪。我嘗試了幾種Flash分配方式 - 結果相同。這種行爲只在我的項目中的這個地方。
我使用rails 3.2.8,inherited_resources 1.3.1,如果它可能有用。
UPD。問題出在Javascript後,加入後
$(function(){
$('.placement-link').on('click', function(){
$("#placement_form").submit();
});
})
一切正常!
而讓Flash消失了,我說。它很古老,想要永遠離開。 – amn
@amn,這不是關於Adobe Flash,它是Ruby on Rails框架中的flash消息=) –
@DenisTataurov stackoverflow不知道你的意圖,並且存在rails-flash標記 – nurettin