【发布时间】:2012-10-04 09:08:49
【问题描述】:
在我的项目中,我有一个地方,闪存数据正在消失。 我的控制器(无关代码已被删除):
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();
});
})
所以,当我点击展示位置链接时,它会重定向到我的视图,但没有闪光灯。很奇怪。我尝试了几种快速分配方式——结果相同。这种行为只出现在我项目的这个地方。
我正在使用 rails 3.2.8,inherited_resources 1.3.1,如果它可能有用的话。
UPD。添加
后,问题出在 Javascript 上$(function(){
$('.placement-link').on('click', function(){
$("#placement_form").submit();
});
})
一切正常!
【问题讨论】:
-
让 Flash 消失,我说。它老了,想离开永恒。
-
@amn,这与 Adobe Flash 无关,它是 Ruby on Rails 框架中的 Flash 消息 =)
-
@DenisTataurov stackoverflow 不知道你的意图,还有一个 rails-flash 标签
标签: ruby-on-rails ruby-on-rails-3.2 rails-flash