Hi,

I'm having an issue with some routes in my apps, the apps are the same
app the only difference is that I use one for testing and the other for
production stored in different directories lets say 'test' and 'prod'.

The applications work with phusion passenger and their work in a virtual
host.

The thing is that in my routes.rb I have this code for both apps:

map.connect '', :controller => 'controllerName'

It seems that all worked just fine until I tested a form and the
resulting url was something like this: www.name.com/controllerName when
the correct url must be something like this
www.name.com/test/controllerName.

The form that give me this problem is this one:

form action="../controllerName/" method="post"

form action="/controllerName/" method="post"

I guess this will happen with every form that redirect to the controller
set in the map.connect like the default controller.

Someone knows a solution for this?

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Colin Law at Jan 19, 2012 at 8:59 pm

    On 19 January 2012 20:42, art tav wrote:
    Hi,

    I'm having an issue with some routes in my apps, the apps are the same
    app the only difference is that I use one for testing and the other for
    production stored in different directories lets say 'test' and 'prod'.

    The applications work with phusion passenger and their work in a virtual
    host.

    The thing is that in my routes.rb I have this code for both apps:

    map.connect '', :controller => 'controllerName'

    It seems that all worked just fine until I tested a form and the
    resulting url was something like this: www.name.com/controllerName when
    the correct url must be something like this
    www.name.com/test/controllerName.

    The form that give me this problem is this one:

    form action="../controllerName/" method="post"

    form action="/controllerName/" method="post"
    I hesitate to reply because I do not fully understand what you are
    doing so anything I say may be rubbish. However I believe that the
    url generated by a commit action of a form (which I think is what you
    are referring to) is nothing to do with anything in routes.rb, it is
    purely determined by the html of the page and, if it is a relative
    url, then the url of the current page. The routes.rb file is only
    referenced after the post is received to determine where to send it.
    Secondly you say that the form giving the problem is "this one" then
    show us two form tags.
    Thirdly, and this is the bit I don't understand and so hope to learn
    more, why are you specifying the controller name in the action and why
    the ../ or / on the front?

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Jan 19, 2012 at 9:23 pm

    On 19 January 2012 20:58, Colin Law wrote:
    ...
    I hesitate to reply because I do not fully understand what you are
    doing so anything I say may be rubbish.  However I believe that the
    url generated by a commit action of a form (which I think is what you
    are referring to) is nothing to do with anything in routes.rb, it is
    purely determined by the html of the page and, if it is a relative
    url, then the url of the current page.
    To correct my own post, if one uses one of the _path routing methods
    then the html generated is of course determined by the contents of
    routes.rb

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Art tav at Jan 19, 2012 at 9:50 pm

    Colin Law wrote in post #1041687:
    On 19 January 2012 20:42, art tav wrote:


    form action="/controllerName/" method="post"
    I hesitate to reply because I do not fully understand what you are
    doing so anything I say may be rubbish. However I believe that the
    url generated by a commit action of a form (which I think is what you
    are referring to) is nothing to do with anything in routes.rb, it is
    purely determined by the html of the page and, if it is a relative
    url, then the url of the current page. The routes.rb file is only
    referenced after the post is received to determine where to send it.
    Secondly you say that the form giving the problem is "this one" then
    show us two form tags.
    Thirdly, and this is the bit I don't understand and so hope to learn
    more, why are you specifying the controller name in the action and why
    the ../ or / on the front?

    Colin
    Hi Colin,

    for example this other form don't give this problem

    <form action="../report/c" method="post">

    when I submit this form the route is correct lets say
    www.name.com/test/report/c

    and with the other form the problem is that the /test/ is omitted so it
    lead to a page that doesn't exist.

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Jan 19, 2012 at 10:02 pm

    On 19 January 2012 21:50, art tav wrote:
    Colin Law wrote in post #1041687:
    On 19 January 2012 20:42, art tav wrote:


    form action="/controllerName/" method="post"
    I hesitate to reply because I do not fully understand what you are
    doing so anything I say may be rubbish.  However I believe that the
    url generated by a commit action of a form (which I think is what you
    are referring to) is nothing to do with anything in routes.rb, it is
    purely determined by the html of the page and, if it is a relative
    url, then the url of the current page.  The routes.rb file is only
    referenced after the post is received to determine where to send it.
    Secondly you say that the form giving the problem is "this one" then
    show us two form tags.
    Thirdly, and this is the bit I don't understand and so hope to learn
    more, why are you specifying the controller name in the action and why
    the ../ or / on the front?

    Colin
    Hi Colin,

    for example this other form don't give this problem

    <form action="../report/c" method="post">

    when I submit this form the route is correct lets say
    www.name.com/test/report/c

    and with the other form the problem is that the /test/ is omitted so it
    lead to a page that doesn't exist.
    If you try to answer my questions I will do my best to help.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Art tav at Jan 19, 2012 at 11:01 pm

    Thirdly, and this is the bit I don't understand and so hope to learn
    more, why are you specifying the controller name in the action and why
    the ../ or / on the front?
    The ../ or / at the beginning are used for being certain that the url
    it's created from the root of the application, I found that when using
    html form tags in rails you need to add this to point to the right
    direction but apparently it's only needed when the controller is a
    different from the default controller.

    When you use that syntax directing the commit to the default controller
    you get the problem i'm having...

    So the solution is to write the form in this way if you try to reach an
    action inside the default controller.

    <from action="controllerName/action" method...>

    For any other controller this is correct

    <form action="/controllerName/action" method...>

    or

    <form action="../controllerName/action" method...>

    Also the controller name is need or you will get something like this
    www.name.com/action
    and unless you are aiming to a action in the default controller you will
    get an error there or in my case if you have multiple RoR applications
    in the same server.

    I hope I made myself clear and didn't confuse you

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Jan 20, 2012 at 9:18 am

    On 19 January 2012 23:01, art tav wrote:
    Thirdly, and this is the bit I don't understand and so hope to learn
    more, why are you specifying the controller name in the action and why
    the ../ or / on the front?
    The ../ or / at the beginning are used for being certain that the url
    it's created from the root of the application, I found that when using
    html form tags in rails you need to add this to point to the right
    direction but apparently it's only needed when the controller is a
    different from the default controller.

    When you use that syntax directing the commit to the default controller
    you get the problem i'm having...

    So the solution is to write the form in this way if you try to reach an
    action inside the default controller.

    <from action="controllerName/action" method...>

    For any other controller this is correct

    <form action="/controllerName/action" method...>

    or

    <form action="../controllerName/action" method...>

    Also the controller name is need or you will get something like this
    www.name.com/action
    and unless you are aiming to a action in the default controller you will
    get an error there or in my case if you have multiple RoR applications
    in the same server.
    OK, I have just realised (stupidly) that you are not using the rails
    form helpers (form_tag or form_for).
    When you say that it goes to the wrong url do you mean that POST goes
    to the wrong url or after doing the POST action it then goes to the
    wrong url.
    Are you able to show me the html generated by the form tag (view the
    page source in the browser and copy and paste the relevant html code
    here. Also look in the rails log (log/development.log) and copy and
    paste the relevant section for clicking the submit button.

    Colin
    I hope I made myself clear and didn't confuse you

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


    --
    gplus.to/clanlaw

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 19, '12 at 8:42p
activeJan 20, '12 at 9:18a
posts7
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Colin Law: 4 posts Art tav: 3 posts

People

Translate

site design / logo © 2021 Grokbase