more readable and workable param generation
Oleg
committed Sep 20, 2011
commit 0801500b060bbe79ef7dcc8628265937e051ed64
Showing 1
changed file with
8 additions
and 5 deletions
app/views/cms_admin/files/_index.html.erb
+8
-5
| @@ | @@ -1,11 +1,14 @@ |
| <div id='file_uploads' class='box'> | |
| <% | |
| - | url_param = %w(layout page snippet).inject({}) do |c, type| |
| - | c["#{type}_id"] = @_assigns[type].id if @_assigns[type] && @_assigns[type].id |
| - | c |
| - | end |
| - | url_param = url_param.present?? { :file => url_param } : nil |
| + | key, id = if @layout && !@layout.new_record? |
| + | [:layout_id, @layout.id] |
| + | elsif @page && !@page.new_record? |
| + | [:page_id, @page.id] |
| + | elsif @snippet && !@snippet.new_record? |
| + | [:snippet_id, @snippet.id] |
| + | end |
| + | url_param = key.present?? { :file => { key => id} } : nil |
| %> | |
| <%= form_for :file, :url => cms_admin_site_files_path(@site, url_param), :html => {:multipart => true} do |form| %> | |
| <a id='uploader_button' href='#' class='big button'><%= t('.button') %></a> | |