search for: after_filter

Displaying 20 results from an estimated 82 matches for "after_filter".

2006 Feb 20
3
Rewriting with an after_filter
...39;'m trying to accomplish, however I can''t find how to do it. I think what I want to do is gsub(/UserName/, ''Matthew''), however, I''m clearly missing something. Here''s what I use: <code> class DisplayController < ApplicationController after_filter :customerize def show @contentdivs = Contentdiv.thispage(params[:page]) end def customerize @contentdivs.gsub(/UserName/, ''Matthew'') end end </code> @contentdivs contains bits of html that show.rhtml nicely formats. thispage() selects only those with an...
2006 May 11
1
rendering in after_filter
Hi! Is it possible to render the action within the after_filter method, or is the rendering performed before? I have something like this: class FooController after_filter :send def a @content=... end def b @content=.. end protected def send send_data(@content,...) end end However, when calling the action a or b, the @content doesn...
2009 Jul 14
1
How to add after_filter-style render
Hello I would like to execute specific action rendering something into page after each of my ajax calls. In example I would like to update some div or display an alert. How I imagine it could work is as follows class ApplicationController < ActionController::Base after_filter :do_something_after_each_ajax_call def do_something_after_each_ajax_call if request.xml_http_request? render :update do |page| page << "alert(''doing something!''); end end end end Of course code above will yield with "Can only rende...
2006 Sep 22
6
Using after_filter to control rendering on actions
I have a common failure page that I may need to render to upon failing some test that occurs in an after_filter method. I''d like to use the after_filter to take over the control of the rendering, like so: def test_for_validity some_boolean = my_test return render(:action => ''disqualified'') unless some_boolean @success_controller ||= controller_name @success_action ||=...
2006 Jul 22
0
how to apply before/after_filter to actionmailer
hi, I want to perform some action before/after each email was delivered. How can I apply before/after_filter to actionmailer? Thanks. Best Regards, Zhenjian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060722/8f014133/attachment.html
2006 Mar 21
0
cache and exception safe around_filter (after_filter)
Hi, I was wondering if there is a feature or construct in rails that is guaranteed to run after an action like an around_filter (or after_filter) but will still run regardless of a broken filter chain or thrown exception? Currently I have an around filter setup, and I really require the after part of the filter to run, although if the filter chain is broken via cacheing or an exception is throw, the code is skipped. So for what I need,...
2009 Feb 22
0
Using after_filter to remove image after render
...d_in? user = User.find(session[:user_id]) @image = Image.find(params[:id]) if @image.user_id = user.id if File.exist?(''PATH TO IMAGE'') File.delete(''PATH TO IMAGE'') end end end end and in the controller I have this: after_filter :remove, :only => [:show] --~--~---------~--~----~------------~-------~--~----~ 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 unsu...
2006 Aug 01
8
Decoupled observers for controllers?
In the Rails Recipes book the recipe "Keeping track of who did what" explains how to do decoupled observing of models. In my application I''d like to do a similar thing but watching the controllers. For example, when somebody hits the login method of the Security controller, I''d like to make a note of it. In this case I could observe the User model and watch for
2006 Apr 25
2
Bug in Rails 1.1 implementation of before_filters
...uot;before_filters") instead of before_filters. Similarly, use read_inheritable_attribute("included_actions") instead of included_actions. This is bad because now my code is tied to an implementation detail which would normally be hidden. Incidentally, the same bug also occurs in after_filters and excluded_actions. Cheers, Graham -- Posted via http://www.ruby-forum.com/.
2007 Nov 30
5
render_to_string in an after filter
I''m using render_to_string in an after_filter, which renders a partial that is sent to a web service. Here''s the code: class MyController < ApplicationController after_filter :post_to_webservice def show # show logic end def post_to_webservice stuff = render_to_string :partial => ''stuff'' webservice_post(st...
2006 Mar 10
3
WML sites
Hi all how to make a WML view for rails pages? I''ve tried to create like: <wml> <card> CONTENT </card> </wml> but my phone says unsupported content type... thanks -- Posted via http://www.ruby-forum.com/.
2006 Jul 10
2
Mongrel caching
I am using mongrel to serve static as well as dynamic pages. The static page''s controller contains the following line of code: after_filter {|c| c.cache_page} This code caches that page as a static html page that does not have to be rendered form multiple files (the view and layout). I got the idea to do this form the rails recipes book. It definitely cached the pages. Wen I make changes now, I do not get an updated page. I have c...
2008 Sep 13
2
<meta http-equiv="refresh" content="5"/>
Do you know of any way for me to stick a meta tag in using a before_filter or after_filter or around_filter? <meta http-equiv="refresh" content="5"/> I have been trying to figure out out and just cannot make sense of it. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on...
2013 Feb 28
1
how to use before_filter to decrypt post data
hello, everybody. in ror, we can add a after_filter to a controller. def aes_encrypt response.body = AesHelper.aes_encrypt(response.body) end after_filter :aes_encrypt and all action''s repsonse int the controller can be encrypt. and my question is , how to decrypt data use before_filter, or anything else. ex: i want to post...
2007 Feb 28
1
One page in app keeps rendering as text/plain
...l: no-cache Connection: close Content-Type: text/plain Length: unspecified [text/plain] [ <=> ] 23,615 --.--K/s 10:52:10 ( 15.75 MB/s) - `registration'' saved [23615] I''ve even set an after_filter in application.rb to force the header type like so: after_filter :set_charset def set_charset @headers["Content-Type"] = "text/html; charset=utf-8" end All of my other pages render just fine ... but this is the only one I use a little RJS with. Is that related? An...
2006 May 25
5
Is there a way to abstract the updating of other parts of the page after an Ajax request without putting using the standard view file?
...ow in a table), and updating any associated portions of the page. Is this possible? I can''t see a way of doing it at the moment because render can only be called once. I could just fiddle with the RJS stuff in ActionView but would like to check there isn''t a better way. Maybe an after_filter, but I''m doubtful about that. Thanks, -Jonathan.
2006 Apr 14
2
Puzzled with filters
Hello everyone! I''m trying to create an after filter for all my actions in all controllers. I put it in application controller (application.rb). class ApplicationController < ActionController::Base after_filter :tidyit def tidyit xxxx # syntax error - intentionally end end I have a Example (example_controller.rb) controller with index action. class ExampleController < ActionController::Base def index @result = "Hello, world!" end end When I try to access server:3000...
2005 Nov 03
9
[Idea] session-wide persistent variables
I was thinking about having instance variable stored and fetched from session container automatically before calling an action and after the action is finished. Using methodology of accessors it would look like: class MyController < ActionController::Base persistent_attr :person def alfa person = ''John Smith'' # render as usual view alfa.rhtml with anchor
2007 Dec 23
5
prepend_view_path not working
Now that controllers can have multiple view paths I''ve been playing with themes over the weekend. Running into a view issues. I have a before_filter in the ApplicationController that calls prepend_view_path to add the path of my theme. I even log the view_paths in an after_filter to make sure it made it all the way through. The output looks something like: /path/to/rails_project/themes/default/views:/path/to/rails_project/app/views Yet nothing loads. In the docs it says calling prepend_view_path as an instance method will only effect the current request, which I figured...
2006 Feb 09
6
Getting the name of the calling controller
I know I''ve seen this before, but I can''t find it and Google hasn''t been a help... >From within a controller method, how can I find the name of the requesting controller? For example, if I''m in controller C1 and I do a redirect_to :controller=> ''foo'', :action => ''bar'', how can I find the name of the requesting