Q: URL helper method uses what default :id? I'm new to Rails and had a doubt regarding the link_to method. The second argument should be the url of the link, which one can generate using the url helper methods. However, one may need to pass  :id as an argument of the helper method, which can be done by passing an object (which has :id as one of its attributes).
Well, in one case I did not pass the object to the method (in one of the views). However, the url was still able to obtain the correct :id (presumably using an instance variable defined earlier). 
How did Rails choose a value for :id when I didn't even pass in any object?
Thanks a lot!

Edit
Here's the relevant code:
link_to 'Find Movies With Same Director', same_dir_path   

Here, I am on a "show" page with url /movies/1. The same_dir_path is the helper method for the URL /movies/same_dir/:id where :id would be that of the passed object and movie#same_dir is the controller#action. Note I did not pass any object to the helper method link_to and yet, it takes the :id from the previous url ('1' in this case). The URL isn't even relative to the previous one (the path is different).

This is the controller method (same_dir):
def same_dir    
  @movies = Movie.find(params[:id])

  if (@movies.director.nil? || @movies.director == '')

    flash.keep  
    redirect_to movies_path         
    flash[:warning]="'#{@movies.title}' has no director info"                 
    return

  end   

  @otherMovies = Movie.find_all_by_director(@movies.director)   

end

This is the routes.rb code:
match 'movies/same_dir/:id'=> 'movies#same_dir', :as => :same_dir
resources :movies 


A: After reading your updated question I can provide you with a better answer:
Rails controllers can have default url options via the url_options method. (Doesn't seem to be a very documented feature. (here and here))
By default this method returns the parameters from the current request and that is where the id is coming from.
You can override it, too:
def url_options
  { my_parameter: my_value }.merge(super)
end 


Original answer (might still be useful):
What you are witnessing is most likely a browser feature. For example this code:
link_to "Show", ""

generates this HTML code:
<a href="">Show</a>

If you click that link in a browser it navigates to the empty url relative to the current url, which is in fact equal to the current url.
Another example:
link_to "Publish", :publish

generates: 
<a href="publish">Publish</a>

Now if your current url is http://localhost/articles/1/edit that link will take you to http://localhost/articles/1/publish. (Notice that the final url contains the model ID even though you are not having it in the HTML source)
In both cases your current model ID is preserved by the browser because you are using relative urls. 
This behaviour might give you the illusion of some magical model ID detection, especially because browsers preview the final (=absolute) url when hovering over the link. 
Have a look at the source, I'll bet your generated links do not contain any model IDs.
