host_with_port in config/environment.rb

15 views
Skip to first unread message

Enrico Mail

unread,
Nov 11, 2009, 7:01:00 AM11/11/09
to rubyonra...@googlegroups.com
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
--
Posted via http://www.ruby-forum.com/.

Enrico Mail

unread,
Nov 11, 2009, 8:34:25 AM11/11/09
to rubyonra...@googlegroups.com

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.

Enrico Mail

unread,
Nov 11, 2009, 11:19:31 AM11/11/09
to rubyonra...@googlegroups.com
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 :(

Frederick Cheung

unread,
Nov 11, 2009, 1:07:27 PM11/11/09
to Ruby on Rails: Talk

On Nov 11, 4:19 pm, Enrico Mail <rails-mailing-l...@andreas-s.net>
wrote:
> 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 :(
>

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

> --
> Posted viahttp://www.ruby-forum.com/.

Enrico Mail

unread,
Nov 11, 2009, 2:03:53 PM11/11/09
to rubyonra...@googlegroups.com

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? :(

Reply all
Reply to author
Forward
0 new messages