Rails question

Hi,

It's me again :slight_smile:

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

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.basecamphq.com/ -- Web-based Project Management
http://www.rubyonrails.org/ -- Web-application framework for Ruby
http://www.loudthinking.com/ -- Broadcasting Brain

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

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.basecamphq.com/ -- Web-based Project Management
http://www.rubyonrails.org/ -- Web-application framework for Ruby
http://www.loudthinking.com/ -- Broadcasting Brain

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.

路路路

On Thu, 17 Feb 2005 05:51:18 +0900, Ochronus <ochronus@gmail.com> wrote:

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.basecamphq.com/ -- Web-based Project Management
> http://www.rubyonrails.org/ -- Web-application framework for Ruby
> http://www.loudthinking.com/ -- Broadcasting Brain
>
>
>

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

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.basecamphq.com/ -- Web-based Project Management
http://www.rubyonrails.org/ -- Web-application framework for Ruby
http://www.loudthinking.com/ -- Broadcasting Brain

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

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

Regards,
Ochronus

Tanner Burson wrote:

路路路

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.

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 :confused:

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