ruby - Rails link_to existing route -
i'm trying link action in controller view. when rake routes, see
document_version_file_index /document_versions/:document_version_id/file(.:format) file#index
i think that's route want hit. controller called document_versions_controller , includes action called download want call. when try
<%= link_to linktext, :document_version_file %>
i routing error:
no route matches {:action=>"show", :controller=>"files"}
there no files controller. i'm trying hit document_version controller. doing wrong?
edit: how building route:
resources :document_versions resources :files member 'download', :action => :download resources :document_version end end
edit 2: can step , pretend don't have route in existence already? have view , controller. controller has def download
, named document_versions_controller.rb
, has class documentversionscontroller < applicationcontroller
. how can make route hits download method , call link click in view?
that route requires :document_version_id
argument, can't call straight-up that. way use route be:
document_version_file_index_path(@document_version_file)
i'm not sure why route has index
in name, automatically generated routes don't.
the easy way remember how routes work every :x
type argument in path that's not optional, not inside brackets, provide value in call in order appear.
a route /:a/:b.(:c)
can called x(a,b)
or x(a,b,c)
, either way valid, :c
optional.
Very helpful articles -
ReplyDeletePHP pagination with sortable table on header click
Python Tkinter Frame Widget
Python Tkinter Checkbutton Widget
Python Tkinter Combobox Event Binding
Python Tkinter Combobox
Python Tkinter Text Widget