Rails question

O

Ochronus

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
 
D

David Heinemeier Hansson

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
 
O

Ochronus

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/categories/show/2

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/categories/show/2


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

Thank you,
Ochronus
 
T

Tanner Burson

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/categories/show/2

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/categories/show/2

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://www.all.hu . This should tell the
browser that paths all start relative to that directory, not whatever
the URL appears to be.
 
O

Ochronus

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
 
O

Ochronus

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
 
O

Ochronus

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/some_action

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_PREF/show/1
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/categories/show/1

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,286
Latest member
ChristieSo

Latest Threads

Top