diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ab722cc0..7072396b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -14,6 +14,10 @@ class ApplicationController < ActionController::Base def can_use_image_mode? true end + + def not_found(record_name='record') + raise ActionController::RoutingError.new("#{record_name} not found") + end class AccessDenied < StandardError;end diff --git a/app/controllers/outfits_controller.rb b/app/controllers/outfits_controller.rb index 0ea71a19..7a4685df 100644 --- a/app/controllers/outfits_controller.rb +++ b/app/controllers/outfits_controller.rb @@ -69,6 +69,16 @@ class OutfitsController < ApplicationController format.json { render :json => @outfit } end end + + def start + @species = Species.find_by_name params[:species_name] + @color = Color.find_by_name params[:color_name] + if @species && @color + redirect_to wardrobe_path(:species => @species.id, :color => @color.id) + else + not_found('species/color') + end + end def update if @outfit.update_attributes(params[:outfit]) diff --git a/config/routes.rb b/config/routes.rb index 23be9817..98f9f3ba 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -74,6 +74,7 @@ OpenneoImpressItems::Application.routes.draw do |map| match 'users/top_contributors' => redirect('/users/top-contributors') match '/wardrobe' => 'outfits#edit', :as => :wardrobe + match '/start/:color_name/:species_name' => 'outfits#start' match '/donate' => 'static#donate', :as => :donate match 'image-mode' => 'static#image_mode', :as => :image_mode