In my project i have one place, where flash data is dissapearing. My controller (inessential code has been removed):
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
my show.htm.haml
view:
= 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"
routes for placement:
resource :placement, :controller => 'Placement'
and my js:
$(function(){
$('.placement-link').on('click', function(){
$("#placement_form").submit();
});
})
So, when i click the placement link, it redirects to my view, but with no flash. Very strange. I tryed several ways of flash assigment - the same result. This behavior only in this place in my project.
I'm using rails 3.2.8, inherited_resources 1.3.1, if it may be useful.
UPD. The problem was with Javascript, after adding
$(function(){
$('.placement-link').on('click', function(){
$("#placement_form").submit();
});
})
everything works!
in your
show
action