Im creating plugin for limiting the ip, i have included the plugin name in my controller Controller: class AdminController < ApplicationController acts_as_ratelimit def login session[:user_id] = nil if request.post? user = User.authenticate(params[:name], params[:password]) if user session[:user_id] = user.id redirect_to(:controller=>"products", :action => "new" ) else flash.now[:notice] = "Invalid user/password combination" end end end my plugin was initialize properly but im facing the problem in getting the remote ip in my plugin code . i have included the line request.remote_ip for getting the ip address, im facing the error us undefined method or variable as request Is that any way to get the ip correctly.
@remote_ip = request.remote_ip if apache is behind a mongrel remote_ip might not work and you would have to do something similar: @remote_ip = request.env["HTTP_X_FORWARDED_FOR"] def login @remote_ip = request.remote_ip .. Your code .. logger.error("test: IP: #{@remote_ip}" ) end Check your logs. -- Posted via http://www.ruby-forum.com/.
thank you i got the answer On Fri, Aug 21, 2009 at 8:16 PM, Alpha Blue < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > @remote_ip = request.remote_ip > > if apache is behind a mongrel remote_ip might not work and you would > have to do something similar: > > @remote_ip = request.env["HTTP_X_FORWARDED_FOR"] > > def login > @remote_ip = request.remote_ip > .. > Your code > .. > logger.error("test: IP: #{@remote_ip}" ) > end > > Check your logs. > -- > 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 -~----------~----~----~----~------~----~------~--~---