host_with_port in config/environment.rb

Enrico Mail wrote:

Hello everyone... i'm Italian, sorry for my poor English, but I find myself in difficulties with this method.I don't need to redirect the logout of rubycas in a host other than localhost... when the decoy in "config/environment.rb" of course tells me 'method 'host_with_port' undefined'... I looked in the folder of ruby and i saw that it is defined in Ruby\lib\ruby\gems\1.8\gems\actionpack-2.3.4\lib\action_controller\request.rb, then to invoke it I did the following:

require 'actionpack' ActionController.host_with_port

and gives me this error: "undefined method 'host_with_port' for ActionController::Module (NoMethodError)". How do you? It is defined precisely in that module... I hope that to help me because I do not come out. PS: I use rails 2.3.4

I noticed that the host_with_port method works safely all controller or view, but if I go to use it in config/environment.rb setting a filter rubycas logout so:

CASClient: Frameworks:Rails: configure () Filter. : logout_url = "https://mioservercas/logout?service=http://#\{host\_with\_port\}/" }

tells me that the host_with_port method is undefined... I do the require something? I repeat that this method don't works only in config/environment.rb. I hope have been clearer.

I must configure rubycas logout so:

CASClient::Frameworks::Rails::Filter.configure( :cas_base_url => "https://myservercas/", ... :logout_url => "https://myservercas/logout?service=http://#\{request\.host\_with\_port\}", ... )

and to do so I must change config/environment.rb,but in this file tell me that the request.host_with_port method is undefined...help me :frowning:

I must configure rubycas logout so:

CASClient::Frameworks::Rails::Filter.configure( :cas_base_url => "https://myservercas/", ... :logout_url => "https://myservercas/logout?service=http://#\{request\.host\_with\_port\}", ... )

and to do so I must change config/environment.rb,but in this file tell me that the request.host_with_port method is undefined...help me :frowning:

host_with_port is an instance method on an individual request - you can't call it if you are not in the presence of an individual request.

Fred

Frederick Cheung wrote:

and to do so I must change config/environment.rb,but in this file tell me that the request.host_with_port method is undefined...help me :frowning:

host_with_port is an instance method on an individual request - you can't call it if you are not in the presence of an individual request.

Fred

ok but if i use this method so:

line50:$hostname= request.host_with_port line51:CASClient::Frameworks::Rails::Filter.configure( line52:... line53: :logout_url => line54: "https://myservercas/logout?service=http://#\{$hostname\}", line55:... line56:)

gives me the same error(undefined method request...at line50).I'm in the presence of a request here.I couldn't use "request" and "host_with_port" in environment.rb,because they are undefined.Why? :frowning: