[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Rails question

Ochronus

2/16/2005 1:53:00 PM

Hi,

It's me again :)

I forgot to mention that the nitro app is to be served from a
subdirectory on the server, like www.servername.com/ochronus/nitro_example.

This brought up a former problem of mine: I was not able to deploy a
single rails app to an apache www-root subdirectory, because all the
automatically generated links (link_to, actions, etc.) pointed at
www.servername.com/action instead of
www.servername.com/ochronus/rails_app/action. I couldn't find any
workaround, and even "googling" was no good... Does anyone have an idea?


Thanks in advance,
Ochronus


6 Answers

David Heinemeier Hansson

2/16/2005 8:17:00 PM

0

> This brought up a former problem of mine: I was not able to deploy a
> single rails app to an apache www-root subdirectory, because all the
> automatically generated links (link_to, actions, etc.) pointed at
> www.servername.com/action instead of
> www.servername.com/ochronus/rails_app/action. I couldn't find any
> workaround, and even "googling" was no good... Does anyone have an
> idea?

You can use :application_prefix. You can even set this as a default
rewrite option if all your rewrites needs to be made with this prefix.
Example:

class ApplicationController
protected
def default_url_options(options)
{ :application_prefix => "ochronus/" }
end
end
--
David Heinemeier Hansson,
http://www.basec... -- Web-based Project Management
http://www.rubyon... -- Web-application framework for Ruby
http://www.loudthi... -- Broadcasting Brain



Ochronus

2/16/2005 8:51:00 PM

0

Thanks for your help, I did what you adviced, but the result is weird.

At first load (first time it's opened in the browser) everything's fine,
it generates good urls. Then if I click one of these hrefs, the second
time the page loads, it seemingly adds the prefix _again_

As for an actual example:
First time link:
http://www.all.hu/ochronus/blog/public/categor...

When I click this href, it reloads the page, and the same href changes to:
http://www.all.hu/ochronus/blog/public/ochronus/blog/public/categor...


What could be causing this? How could I avoid it?

Thank you,
Ochronus


David Heinemeier Hansson wrote:
>> This brought up a former problem of mine: I was not able to deploy a
>> single rails app to an apache www-root subdirectory, because all the
>> automatically generated links (link_to, actions, etc.) pointed at
>> www.servername.com/action instead of
>> www.servername.com/ochronus/rails_app/action. I couldn't find any
>> workaround, and even "googling" was no good... Does anyone have an idea?
>
>
> You can use :application_prefix. You can even set this as a default
> rewrite option if all your rewrites needs to be made with this prefix.
> Example:
>
> class ApplicationController
> protected
> def default_url_options(options)
> { :application_prefix => "ochronus/" }
> end
> end
> --
> David Heinemeier Hansson,
> http://www.basec... -- Web-based Project Management
> http://www.rubyon... -- Web-application framework for Ruby
> http://www.loudthi... -- Broadcasting Brain
>
>
>


Tanner Burson

2/16/2005 8:59:00 PM

0

On Thu, 17 Feb 2005 05:51:18 +0900, Ochronus <ochronus@gmail.com> wrote:
> Thanks for your help, I did what you adviced, but the result is weird.
>
> At first load (first time it's opened in the browser) everything's fine,
> it generates good urls. Then if I click one of these hrefs, the second
> time the page loads, it seemingly adds the prefix _again_
>
> As for an actual example:
> First time link:
> http://.../ochronus/blog/public/categor...
>
> When I click this href, it reloads the page, and the same href changes to:
> http://.../ochronus/blog/public/ochronus/blog/public/categor...
>
> What could be causing this? How could I avoid it?
>
Make sure to set the <base href=""> attribute in the HEAD section of
your rhtml template to http://... . This should tell the
browser that paths all start relative to that directory, not whatever
the URL appears to be.

> Thank you,
> Ochronus
>
>
> David Heinemeier Hansson wrote:
> >> This brought up a former problem of mine: I was not able to deploy a
> >> single rails app to an apache www-root subdirectory, because all the
> >> automatically generated links (link_to, actions, etc.) pointed at
> >> www.servername.com/action instead of
> >> www.servername.com/ochronus/rails_app/action. I couldn't find any
> >> workaround, and even "googling" was no good... Does anyone have an idea?
> >
> >
> > You can use :application_prefix. You can even set this as a default
> > rewrite option if all your rewrites needs to be made with this prefix.
> > Example:
> >
> > class ApplicationController
> > protected
> > def default_url_options(options)
> > { :application_prefix => "ochronus/" }
> > end
> > end
> > --
> > David Heinemeier Hansson,
> > http://www.basec... -- Web-based Project Management
> > http://www.rubyon... -- Web-application framework for Ruby
> > http://www.loudthi... -- Broadcasting Brain
> >
> >
> >
>
>


Ochronus

2/16/2005 9:02:00 PM

0

Ok, I found out...

Instead of application_prefix, I rewrote action_prefix, like:

protected
def default_url_options(options)
{ :controller_prefix => "ochronus/" }
end



Thank you again for your help, David!

Regards,
Ochronus

Ochronus wrote:
> Thanks for your help, I did what you adviced, but the result is weird.
>
> At first load (first time it's opened in the browser) everything's fine,
> it generates good urls. Then if I click one of these hrefs, the second
> time the page loads, it seemingly adds the prefix _again_
>
> As for an actual example:
> First time link:
> http://www.all.hu/ochronus/blog/public/categor...
>
> When I click this href, it reloads the page, and the same href changes to:
> http://www.all.hu/ochronus/blog/public/ochronus/blog/public/categor...
>
>
>
> What could be causing this? How could I avoid it?
>
> Thank you,
> Ochronus
>
>
> David Heinemeier Hansson wrote:
>
>>> This brought up a former problem of mine: I was not able to deploy a
>>> single rails app to an apache www-root subdirectory, because all the
>>> automatically generated links (link_to, actions, etc.) pointed at
>>> www.servername.com/action instead of
>>> www.servername.com/ochronus/rails_app/action. I couldn't find any
>>> workaround, and even "googling" was no good... Does anyone have an idea?
>>
>>
>>
>> You can use :application_prefix. You can even set this as a default
>> rewrite option if all your rewrites needs to be made with this prefix.
>> Example:
>>
>> class ApplicationController
>> protected
>> def default_url_options(options)
>> { :application_prefix => "ochronus/" }
>> end
>> end
>> --
>> David Heinemeier Hansson,
>> http://www.basec... -- Web-based Project Management
>> http://www.rubyon... -- Web-application framework for Ruby
>> http://www.loudthi... -- Broadcasting Brain
>>
>>
>>
>
>


Ochronus

2/16/2005 9:09:00 PM

0

Wow, that's a fine solution, thank you... I should have thought of it
myself, it's pure html :) thank you! It's actually simpler to modify the
prefix(es), but this is a surely working fallback solution if
something goes wrong :)

It's good to have such helpful people in this community, I hope one day
I can requite this :)


Regards,
Ochronus


Tanner Burson wrote:
>
> Make sure to set the <base href=""> attribute in the HEAD section of
> your rhtml template to http://... . This should tell the
> browser that paths all start relative to that directory, not whatever
> the URL appears to be.
>
>


Ochronus

2/16/2005 9:26:00 PM

0

Hmmmm nope... not good

If I set up controller_prefix well, all links work as expected (have
the good urls), BUT actions (such as form submits, editing, etc.) have
the wrong url (since they don't have prefix). If I set action_prefix, it
messes up everything, the scheme is as follows:

http://www.all.hu/CONTROLLER_PREFIX/some_controller/ACTION_PREFIX/s...

ACTION_PREFIX is not needed in normal links, but needed at form submits
for example.


E.g:
http://www.all.hu/CONTR_PREF/categories/ACTION_P...
is an URL to show articles in a certain category.
in this link ACTION_PREF should be "", so the link is:
http://www.all.hu/CONTR_PREF/categor...

But in case of an article editing form, whose submit link is generated
automatically from :action => target , the action prefix should have a
value.


I have _no_ idea how to resolve this :/


Regards,
Ochronus



Ochronus wrote:
> Ok, I found out...
>
> Instead of application_prefix, I rewrote action_prefix, like:
>
> protected
> def default_url_options(options)
> { :controller_prefix => "ochronus/" }
> end
>
>
>
> Thank you again for your help, David!
>
> Regards,
> Ochronus
>