This project is archived and is in readonly mode.
url_for documentation - only_path
-
heidmo
- Assigned user set to CancelProfileIsBroken
Yeah I agree, it should say "(true by default)" instead of false.
-
CancelProfileIsBroken
- Assigned user cleared.
-
Derek McLoughlin
url_for behaves differently depending on whether it is called from within a view or within a controller.
From within a view, the default is a relative URL, and :only_path => false gives you the full URL.
From within a controller, the default is a full URL, and :only_path => true gives you the relative URL.
Sample code with a scaffold 'Person'
Controller:
@@@ruby def show@person = Person.find(params[:id]) @person_url = url_for(@person) @person_url_only_path_false = url_for(:id => params[:id], :only_path => false) @person_url_only_path_true = url_for(:id => params[:id], :only_path => true)end
show.rhtml @@@ruby <p>IN THE VIEW</p> <p>url_for(@person) = <%= url_for(@person) %></p> <p>url_for(:id => 1, :only_path => false) = <%= url_for(:id => 1, :only_path => false) %></p> <p>url_for(:id => 1, :only_path => true) = <%= url_for(:id => 1, :only_path => true) %></p>
<p>FROM THE CONTROLLER</p> <p>url_for(@person) = <%= @person_url %></p> <p>url_for(:id => 1, :only_path => false) = <%= @person_url_only_path_false %></p> <p>url_for(:id => 1, :only_path => true) = <%= @person_url_only_path_true %></p>The documentation is correct.
-
Andrew Vit
IMHO, it would read better if the option were named :full_url, :full_path, or :fully_qualified.
It's always clearer if the option is stated as a positive, so the default can be false. (For that matter, why isn't there a path_for method like with the other url helper methods?)
-
Santiago Pastorino
- State changed from new to open
- Importance changed from to
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale