Permalink
Browse files

a little more RESTful

  • Loading branch information...
1 parent 53c7ba9 commit c876032a4fff0ccc58cae46f067ac42cfda6cab1 @jzw committed Jul 19, 2011
@@ -1,18 +1,18 @@
-class Admin::ProductImportController < Admin::BaseController
-
+class Admin::ProductImportsController < Admin::BaseController
+
#Sorry for not using resource_controller railsdog - I wanted to, but then... I did it this way.
#Verbosity is nice?
#Feel free to refactor and submit a pull request.
-
+
def index
redirect_to :action => :new
end
-
+
def new
@product_import = ProductImport.new
end
-
-
+
+
def create
@product_import = ProductImport.create(params[:product_import])
Delayed::Job.enqueue ImportProducts::ImportJob.new(@product_import, @current_user)
@@ -1,8 +1,7 @@
<h2><%= t('form.product_import.heading') %></h2>
-
<%= render "shared/error_messages", :target => @product_import %>
-<%= form_for(:product_import, :url => admin_product_import_index_path, :method => :post, :html => { :multipart => true }) do |f| %>
+<%= form_for([:admin, @product_import], :method => :post, :html => { :multipart => true }) do |f| %>
<fieldset>
<%= f.field_container :data_file do %>
<%= f.label :data_file, t('form.product_import.new.data_file') %>
@@ -0,0 +1 @@
+Delayed::Worker.backend = :active_record
View
@@ -1,6 +1,6 @@
en:
product_import_processing: 'Thanks, your import has been added to the queue for processing. You will receive an email confirming the import once it has completed.'
- product_import_index: 'Import Products'
+ product_imports: 'Import Products'
form:
product_import:
heading: 'Import Products from CSV'
View
@@ -1,5 +1,5 @@
Rails.application.routes.draw do
namespace :admin do
- resources :product_import, :only => [:index, :new, :create]
+ resources :product_imports, :only => [:index, :new, :create]
end
end
@@ -1,6 +1,6 @@
class ImportProductsHooks < Spree::ThemeSupport::HookListener
# custom hooks go here
insert_after :admin_tabs do
- %(<%= tab(:product_import_index) %>)
+ %(<%= tab(:product_imports) %>)
end
end

0 comments on commit c876032

Please sign in to comment.