Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

a little more RESTful

  • Loading branch information...
commit c876032a4fff0ccc58cae46f067ac42cfda6cab1 1 parent 53c7ba9
Zac Williams authored
12 app/controllers/admin/product_import_controller.rb → app/controllers/admin/product_imports_controller.rb
... ... @@ -1,18 +1,18 @@
1   -class Admin::ProductImportController < Admin::BaseController
2   -
  1 +class Admin::ProductImportsController < Admin::BaseController
  2 +
3 3 #Sorry for not using resource_controller railsdog - I wanted to, but then... I did it this way.
4 4 #Verbosity is nice?
5 5 #Feel free to refactor and submit a pull request.
6   -
  6 +
7 7 def index
8 8 redirect_to :action => :new
9 9 end
10   -
  10 +
11 11 def new
12 12 @product_import = ProductImport.new
13 13 end
14   -
15   -
  14 +
  15 +
16 16 def create
17 17 @product_import = ProductImport.create(params[:product_import])
18 18 Delayed::Job.enqueue ImportProducts::ImportJob.new(@product_import, @current_user)
3  app/views/admin/product_import/new.html.erb → app/views/admin/product_imports/new.html.erb
... ... @@ -1,8 +1,7 @@
1 1 <h2><%= t('form.product_import.heading') %></h2>
2 2
3   -
4 3 <%= render "shared/error_messages", :target => @product_import %>
5   -<%= form_for(:product_import, :url => admin_product_import_index_path, :method => :post, :html => { :multipart => true }) do |f| %>
  4 +<%= form_for([:admin, @product_import], :method => :post, :html => { :multipart => true }) do |f| %>
6 5 <fieldset>
7 6 <%= f.field_container :data_file do %>
8 7 <%= f.label :data_file, t('form.product_import.new.data_file') %>
1  config/initializers/delayed_job.rb
... ... @@ -0,0 +1 @@
  1 +Delayed::Worker.backend = :active_record
2  config/locales/en.yml
... ... @@ -1,6 +1,6 @@
1 1 en:
2 2 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.'
3   - product_import_index: 'Import Products'
  3 + product_imports: 'Import Products'
4 4 form:
5 5 product_import:
6 6 heading: 'Import Products from CSV'
2  config/routes.rb
... ... @@ -1,5 +1,5 @@
1 1 Rails.application.routes.draw do
2 2 namespace :admin do
3   - resources :product_import, :only => [:index, :new, :create]
  3 + resources :product_imports, :only => [:index, :new, :create]
4 4 end
5 5 end
2  lib/import_products_hooks.rb
... ... @@ -1,6 +1,6 @@
1 1 class ImportProductsHooks < Spree::ThemeSupport::HookListener
2 2 # custom hooks go here
3 3 insert_after :admin_tabs do
4   - %(<%= tab(:product_import_index) %>)
  4 + %(<%= tab(:product_imports) %>)
5 5 end
6 6 end

0 comments on commit c876032

Please sign in to comment.
Something went wrong with that request. Please try again.