Browse the Ruby on Rails Community.

You are here: Forums Ask a Rails expert changing base url ...

Replytotopic

changing base url

Posted in Forums : Ask a Rails expert

 
Profile

Authority 0
Posting Rating 0
Sign in to rate this post

Hey, I have a rails app that is viewed in a frame of another site.
My problem is all my ‘links’ and ‘redirects’ (basically anything that relates to ‘url_for’) are directing out of the frame and present the links on their own…I’ll try to explain better:

Lets say my domain is: www.ror.com
my home page is www.ror.com/home/index
but u should view it using: www.frames.com/myapp/home/index
(meaning my site should be viewed only through a frame in the www.frames.com website)
from the home page u can move with a link to a different page:
lets say: link_to(‘link’ :action => ‘show’)
now when u press the link the browser will go to www.ror.com/home/show
but I want it to go to www.frames.com/myapp/home/show

In short I want to replace the base of all my urls from ‘www.ror.com’ to ‘www.frames.com/myapp’

Thnx !

 
Profile

Authority 62
Posting Rating 99
Sign in to rate this post

try to add in routes.rb after
ActionController::Routing::Routes.draw do |map|
this line
ActionController::AbstractRequest.relative_url_root = “http:// www.frames.com/myapp
I used it to change relative_url, but not to another domain. I hope this helps

 
Profile

Authority 0
Posting Rating 0
Sign in to rate this post

thnx for the reply
tried it but it just adds the url to the end of the original base url…
so now it looks something like: www.ror.com/www.frames.com/myapp
god this is annoying…

 
20064666954644d813e6326

Authority 0
Posting Rating 79
Sign in to rate this post

http://api.rubyonrails.org/classes/ActionController/Base.html#M000455

Putting this in your controller/application.rb should do what you are looking for.

def default_url_options(options)
  { :host => 'www.frames.com/myapp' }
end

Replytotopic

Other Recent Topics

Ask a Rails expert : how to execute the url from my controller

Ask a Rails expert : conditional action caching multiple mongrel clusters

Ask a Rails expert : Using like command in RoR

Ask a Rails expert : Apache ActionController:RoutingError

Ask a Rails expert : Multiple csv file upload based on data in a form

Ask a Rails expert : Exception error code

Ask a Rails expert : Tracking down an issue

Ask a Rails expert : Thread Vs Transaction

Ask a Rails expert : implementing whitelist plugin

Ask a Rails expert : Validation helper

Formatting Help
  • *bold*       _italics_      
    bq. (quotes)
  • "DSC":http://www.dsc.net
  • * or # (lists)
or cancel