Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

a little more RESTful

  • Loading branch information...
commit c876032a4fff0ccc58cae46f067ac42cfda6cab1 1 parent 53c7ba9
@jzw authored
View
12 app/controllers/admin/product_import_controller.rb → app/controllers/admin/product_imports_controller.rb
@@ -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)
View
3  app/views/admin/product_import/new.html.erb → app/views/admin/product_imports/new.html.erb
@@ -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') %>
View
1  config/initializers/delayed_job.rb
@@ -0,0 +1 @@
+Delayed::Worker.backend = :active_record
View
2  config/locales/en.yml
@@ -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
2  config/routes.rb
@@ -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
View
2  lib/import_products_hooks.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.