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:
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?
…
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
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
When you use that syntax directing the commit to the default controller
or
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.
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.
For any other controller this is correct
or
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.