I need to enable Flash message with each request in my application. e.g. if i have action on addFeed, after this action is executed, I have a render :partial ''showfeed'' but i also want to enable a Flash Message for the action ''Feed SAved'' I want to do this with every action in my application? What would be the best way to approach this? amy thoughts? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rails junkie wrote:> I need to enable Flash message with each request in my application. > e.g. if i have action on addFeed, after this action is executed, I > have a render :partial ''showfeed'' but i also want to enable a Flash > Message for the action ''Feed SAved'' > I want to do this with every action in my application? > What would be the best way to approach this? > > amy thoughts?In my app, what i did was extend JavaScriptGenerator: def ajax_flash_notice(message) id = ''notice_wrapper'' html = render(:partial => ''global/ajax_system_flash'', :locals => {:message => message}) empty_str = "" #html = render(*options_for_render) record "Element.update(#{id.inspect}, #{html.inspect})" record "setTimeout(''Element.update(#{id.inspect}, #{empty_str.inspect})'', 10000)" end in controller action: i set flash.now[:message] = ''blah blah'' in .rjs page.ajax_flash_notice(flash[:message]) I dunno if its the best implementation but it works for me. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks. i will give it a shot On Apr 6, 5:49 am, Francis Sinson <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Rails junkie wrote: > > I need to enable Flash message with each request in my application. > > e.g. if i have action on addFeed, after this action is executed, I > > have a render :partial ''showfeed'' but i also want to enable a Flash > > Message for the action ''Feed SAved'' > > I want to do this with every action in my application? > > What would be the best way to approach this? > > > amy thoughts? > > In my app, what i did was extend JavaScriptGenerator: > > def ajax_flash_notice(message) > id = ''notice_wrapper'' > html = render(:partial => > ''global/ajax_system_flash'', :locals => {:message => message}) > empty_str = "" > #html = render(*options_for_render) > record "Element.update(#{id.inspect}, > #{html.inspect})" > record "setTimeout(''Element.update(#{id.inspect}, > #{empty_str.inspect})'', 10000)" > > end > > in controller action: > > i set flash.now[:message] = ''blah blah'' > > in .rjs > > page.ajax_flash_notice(flash[:message]) > > I dunno if its the best implementation but it works for me. > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Francis, call me dumb but i am still trying to understand rails architecture. Now my problem with that example you gave me to putting it togehter Here is what I am thinking def ajax_flash_notice will go in Application.rb In my controller, I will simpy set Flash message Now How does this .rjs file get called? this is my code Feed.save Flash[type]="Task saved" render : partial "showFeed" Now how does rjs come into picture here? I really apreciate your time. Thanks railsjunkie On Apr 6, 11:23 am, "Rails junkie" <ABoxForTheOtherSt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks. i will give it a shot > > On Apr 6, 5:49 am, Francis Sinson <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > > > Rails junkie wrote: > > > I need to enable Flash message with each request in my application. > > > e.g. if i have action on addFeed, after this action is executed, I > > > have a render :partial ''showfeed'' but i also want to enable a Flash > > > Message for the action ''Feed SAved'' > > > I want to do this with every action in my application? > > > What would be the best way to approach this? > > > > amy thoughts? > > > In my app, what i did was extend JavaScriptGenerator: > > > def ajax_flash_notice(message) > > id = ''notice_wrapper'' > > html = render(:partial => > > ''global/ajax_system_flash'', :locals => {:message => message}) > > empty_str = "" > > #html = render(*options_for_render) > > record "Element.update(#{id.inspect}, > > #{html.inspect})" > > record "setTimeout(''Element.update(#{id.inspect}, > > #{empty_str.inspect})'', 10000)" > > > end > > > in controller action: > > > i set flash.now[:message] = ''blah blah'' > > > in .rjs > > > page.ajax_flash_notice(flash[:message]) > > > I dunno if its the best implementation but it works for me. > > > -- > > Posted viahttp://www.ruby-forum.com/.- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---