OSDN Git Service

idを渡す部分でExceptionが発生しないよう修正
authorTaro Matsuzawa aka. btm <btm@tech.email.ne.jp>
Sun, 4 Sep 2011 06:26:33 +0000 (15:26 +0900)
committerTaro Matsuzawa aka. btm <btm@tech.email.ne.jp>
Sun, 4 Sep 2011 06:26:33 +0000 (15:26 +0900)
33 files changed:
app/controllers/accounts_controller.rb
app/controllers/admin/admin_users_controller.rb
app/controllers/admin/authorities_controller.rb
app/controllers/admin/base_controller.rb
app/controllers/admin/campaigns_controller.rb
app/controllers/admin/categories_controller.rb
app/controllers/admin/customers_controller.rb
app/controllers/admin/feature_products_controller.rb
app/controllers/admin/features_controller.rb
app/controllers/admin/mail_magazine_templates_controller.rb
app/controllers/admin/mail_magazines_controller.rb
app/controllers/admin/new_informations_controller.rb
app/controllers/admin/orders_controller.rb
app/controllers/admin/plugins_controller.rb
app/controllers/admin/product_styles_controller.rb
app/controllers/admin/products_controller.rb
app/controllers/admin/service_cooperations_controller.rb
app/controllers/admin/service_cooperations_templates_controller.rb
app/controllers/admin/shops_controller.rb
app/controllers/admin/style_categories_controller.rb
app/controllers/admin/styles_controller.rb
app/controllers/admin/suppliers_controller.rb
app/controllers/campaigns_controller.rb
app/controllers/cart_controller.rb
app/controllers/image_resource_controller.rb
app/controllers/portal_controller.rb
app/controllers/products_controller.rb
app/controllers/questionnaires_controller.rb
app/controllers/retailers_controller.rb
spec/controllers/admin/campaigns_controller_spec.rb
spec/controllers/admin/new_informations_controller_spec.rb
spec/controllers/admin/service_cooperations_controller_spec.rb
spec/controllers/admin/service_cooperations_templates_controller_spec.rb

index ab82855..a5b79ca 100644 (file)
@@ -214,7 +214,7 @@ class AccountsController < BaseController
   end
 
   def history_show
-    @order = @login_customer.orders.find_by_id(params[:id])
+    @order = @login_customer.orders.find_by_id(params[:id].to_i)
     raise ActiveRecord::RecordNotFound unless @order
     @order_delivery = @order.order_deliveries[0]
   end
@@ -301,7 +301,7 @@ class AccountsController < BaseController
     @stage = (params[:stage] || 0).to_i
     params[:done] && !params[:back] and return delivery_update
     @id = params[:id].to_i
-    @delivery_address = find_delivery_address @login_customer, params[:id]
+    @delivery_address = find_delivery_address @login_customer, params[:id].to_i
     if request.method == :post
       get_delivery_address
     end
@@ -317,7 +317,7 @@ class AccountsController < BaseController
   def delivery_update
     @popup = !params[:popup].blank? && params[:popup] == "true"
     @id = params[:id].to_i
-    @delivery_address = find_delivery_address @login_customer, params[:id]
+    @delivery_address = find_delivery_address @login_customer, params[:id].to_i
     @delivery_address.attributes = params[:delivery_address]
     unless @delivery_address.valid?
       return render(:action => 'delivery_edit')
@@ -345,7 +345,7 @@ class AccountsController < BaseController
       if params[:back]
         return (@popup ? delivery_edit_popup : delivery_edit)
       end
-      @delivery_address = find_delivery_address @login_customer, params[:id]
+      @delivery_address = find_delivery_address @login_customer, params[:id].to_i
     end
     @delivery_address.attributes = params[:delivery_address] if @delivery_address
     if @delivery_address && @delivery_address.save
@@ -365,7 +365,7 @@ class AccountsController < BaseController
   end
 
   def delivery_destroy
-    @delivery_address = find_delivery_address @login_customer, params[:id]
+    @delivery_address = find_delivery_address @login_customer, params[:id].to_i
     if @delivery_address and @delivery_address.destroy
       flash.now[:notice] = '削除しました。'
     else
index a27dba8..be28256 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 class Admin::AdminUsersController < Admin::BaseController
   resource_controller
   before_filter :admin_permission_check_member
@@ -17,7 +18,7 @@ class Admin::AdminUsersController < Admin::BaseController
   [create, update].each do |action|
     action.wants.html do
       if params[:id].to_i == session[:admin_user].id
-        if AdminUser.find(params[:id]).retailer_id != session[:admin_user].retailer_id
+        if AdminUser.find(params[:id].to_i).retailer_id != session[:admin_user].retailer_id
           redirect_to :controller => "admin/accounts", :action => "logout"
         else
           redirect_to :action => "index"
@@ -36,7 +37,7 @@ class Admin::AdminUsersController < Admin::BaseController
 
   edit.before do
     unless session[:admin_user].master_shop?
-      raise ActiveRecord::RecordNotFound if AdminUser.find(params[:id]).retailer_id != session[:admin_user].retailer_id
+      raise ActiveRecord::RecordNotFound if AdminUser.find(params[:id].to_i).retailer_id != session[:admin_user].retailer_id
     end
   end
 
@@ -51,7 +52,7 @@ class Admin::AdminUsersController < Admin::BaseController
 
   #稼働/非稼働チェック(Ajax)
   def update_activity
-    record = AdminUser.find_by_id(params[:id])
+    record = AdminUser.find_by_id(params[:id].to_i)
     if params[:activity] == "true"
       record.update_attribute(:activity, true)
     elsif params[:activity] == "false"
index 91a3326..27ed7a9 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 class Admin::AuthoritiesController < Admin::BaseController
   #共通
   resource_controller
@@ -41,7 +42,7 @@ class Admin::AuthoritiesController < Admin::BaseController
 
     if type
       back_to = "edit"
-      @authority = Authority.find_by_id(params[:id])
+      @authority = Authority.find_by_id(params[:id].to_i)
       @authority.attributes = params[:authority]
     else
       back_to = "new"
index 4683a29..bdf808b 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 class Admin::BaseController < ApplicationController
   before_filter :load_system
   before_filter :load_admin
@@ -10,21 +11,21 @@ class Admin::BaseController < ApplicationController
   }
   def up
     get_model(params[:model])
-    @record = @model.find_by_id(params[:id])
+    @record = @model.find_by_id(params[:id].to_i)
     @record.move_higher
     @record.save
   end
 
   def down
     get_model(params[:model])
-    @record = @model.find_by_id(params[:id])
+    @record = @model.find_by_id(params[:id].to_i)
     @record.move_lower
     @record.save
   end
 
   def change_position
     get_model
-    @record = @model.find_by_id(params[:id])
+    @record = @model.find_by_id(params[:id].to_i)
     @record.insert_at(params[:position])
     @record.save
   end
index 30d7623..b850770 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 require 'kconv'
 
 class Admin::CampaignsController < Admin::BaseController
@@ -26,9 +27,9 @@ class Admin::CampaignsController < Admin::BaseController
   end
 
   def csv_download
-    campaign = Campaign.find(params[:id])
+    campaign = Campaign.find(params[:id].to_i)
     result = Campaign.csv(campaign)
-    filename = "campaign#{params[:id]}_#{Time.now.strftime('%Y%m%d%H%M%S')}.csv"
+    filename = "campaign#{params[:id].to_i}_#{Time.now.strftime('%Y%m%d%H%M%S')}.csv"
     headers['Content-Type'] = "application/octet-stream; name=#{filename}"
     headers['Content-Disposition'] = "attachment; filename=#{filename}"
     render :text => Iconv.conv('cp932', 'UTF-8', result)
@@ -36,14 +37,14 @@ class Admin::CampaignsController < Admin::BaseController
 
   def campaign_design
     @type = params[:type]
-    @id = params[:id]
+    @id = params[:id].to_i
     @campaign = Campaign.find(:first, :conditions=>["id=?", @id])
     get_form_names(@type)
   end
 
   def campaign_design_update
     @campaign.attributes = params[:campaign]
-    @id = params[:id]
+    @id = params[:id].to_i
     @type = params[:type]
 
     get_form_names(@type)
@@ -57,7 +58,7 @@ class Admin::CampaignsController < Admin::BaseController
   end
 
   def campaign_preview
-    @id = params[:id]
+    @id = params[:id].to_i
     @type = params[:type]
     @campaign = Campaign.find(:first, :conditions=>["id=?", @id])
     unless @campaign.product_id.blank?
@@ -106,7 +107,7 @@ class Admin::CampaignsController < Admin::BaseController
   private
 
   def design_init
-    @campaign = Campaign.find_by_id(params[:id])
+    @campaign = Campaign.find_by_id(params[:id].to_i)
   end
 
   def get_form_names(type)
index e1ad2eb..ca50e6c 100644 (file)
@@ -3,7 +3,7 @@ class Admin::CategoriesController < Admin::BaseController
   before_filter :master_shop_check
 
   index.before do
-    @category = Category.find_by_id(params[:id])
+    @category = Category.find_by_id(params[:id].to_i)
     if @category
       params[:category_id] ||= @category.parent_id 
     end
index 7be276c..e2a6727 100644 (file)
@@ -38,8 +38,8 @@ class Admin::CustomersController < Admin::BaseController
   edit.before do
     get_customer
 
-    @order_count = Order.count(:conditions => ["customer_id=?", params[:id]])
-    @orders = Order.find(:all, :conditions => ["customer_id=?", params[:id]],
+    @order_count = Order.count(:conditions => ["customer_id=?", params[:id].to_i])
+    @orders = Order.find(:all, :conditions => ["customer_id=?", params[:id].to_i],
       :include => :order_deliveries, :order => "orders.id,order_deliveries.id")
     get_admin_customer_payment
   end
@@ -97,7 +97,7 @@ class Admin::CustomersController < Admin::BaseController
   private
 
   def get_customer
-    @customer = Customer.find_by_id(params[:id])
+    @customer = Customer.find_by_id(params[:id].to_i)
     @customer.attributes = params[:customer]
   end
 
index 94a8505..456c434 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 class Admin::FeatureProductsController < Admin::BaseController
   #共通
   resource_controller
@@ -6,7 +7,7 @@ class Admin::FeatureProductsController < Admin::BaseController
 
   #indexの前処理
   index.before do
-    @feature = Feature.find_by_id(params[:feature_id])
+    @feature = Feature.find_by_id(params[:feature_id].to_i)
     if @feature
       @feature_products = @feature.feature_products
     else
@@ -17,8 +18,8 @@ class Admin::FeatureProductsController < Admin::BaseController
   
   #newの前処理
   new_action.before do
-    #@feature = Feature.find_by_id(params[:feature_id])
-    @feature_product = FeatureProduct.new({:feature_id => params[:feature_id]})
+    #@feature = Feature.find_by_id(params[:feature_id].to_i)
+    @feature_product = FeatureProduct.new({:feature_id => params[:feature_id].to_i})
     @feature_product.attributes = params[:feature_product]
   end
   
@@ -75,7 +76,7 @@ class Admin::FeatureProductsController < Admin::BaseController
   def set_resource_old
     #画像入力欄に選択された場合のみ=>選択した画像
     #それ以外、商品一覧の画像で表示・登録
-    product = Product.find_by_id(params[:feature_product][:product_id]) 
+    product = Product.find_by_id(params[:feature_product][:product_id].to_i
     small_resource = product.small_resource if product
     if params[:feature_product_image_resource_old_id] && params[:feature_product_image_resource_old_id] == 0.to_s && params[:feature_product][:image_resource].blank?
       @feature_product[:image_resource_id] = small_resource.id
index e2aba90..7893dd9 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 class Admin::FeaturesController < Admin::BaseController
   #共通
   resource_controller
@@ -30,7 +31,7 @@ class Admin::FeaturesController < Admin::BaseController
   #確認画面
   def confirm
     if params[:id]
-      @feature = Feature.find_by_id(params[:id])
+      @feature = Feature.find_by_id(params[:id].to_i)
       @feature.attributes = params[:feature]
     else  
       @feature = Feature.new(params[:feature])
index 3de9965..9c8deaf 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 class Admin::MailMagazineTemplatesController < Admin::BaseController
   resource_controller
   mobile_filter
@@ -16,7 +17,7 @@ class Admin::MailMagazineTemplatesController < Admin::BaseController
   end
 
   def preview
-    @mail_magazine_template = MailMagazineTemplate.find_by_id(params[:id]) || MailMagazineTemplate.new
+    @mail_magazine_template = MailMagazineTemplate.find_by_id(params[:id].to_i) || MailMagazineTemplate.new
     unless @mail_magazine_template.id
       flash.now[:error] = "データがありません"
     end
index 4d9806e..72274d2 100644 (file)
@@ -225,14 +225,14 @@ class Admin::MailMagazinesController < Admin::BaseController
   end
 
   def preview
-    mm = MailMagazine.find(params[:id])
+    mm = MailMagazine.find(params[:id].to_i)
     @subject = mm.subject
     @body = mm.body.gsub(/\n/,'<br/>') if mm.body
     render :layout=>false
   end
 
   def condition_view
-    mm = MailMagazine.find(params[:id])
+    mm = MailMagazine.find(params[:id].to_i)
     @condition = {}
     if mm && mm.condition
       @condition = YAML.load(mm.condition)
index 10c79a3..7715a4b 100644 (file)
@@ -12,7 +12,7 @@ class Admin::NewInformationsController < Admin::BaseController
   end
 
   def confirm
-    @new_information = NewInformation.find_by_id(params[:id]) || NewInformation.new
+    @new_information = NewInformation.find_by_id(params[:id].to_i) || NewInformation.new
     @new_information.attributes = params[:new_information]
     unless @new_information.valid?
       #redirect_to :action => (params[:id].blank? ? "new" : "edit")
@@ -34,9 +34,10 @@ class Admin::NewInformationsController < Admin::BaseController
     #params[:id] = params[:id] || params[:new_information][:id]
     #p params[:id]
     unless params[:new_information].blank?
-      @new_information = NewInformation.find_by_id(params[:new_information][:id])
+      @new_information = NewInformation.find_by_id(params[:new_information][:id].to_i)
+      raise ActiveRecord::RecordNotFound unless @new_information
       @new_information.attributes = params[:new_information]
-      params[:id] = params[:new_information][:id]
+      params[:id] = params[:new_information][:id].to_i
     end
   end
 
index c22f1c3..a311c75 100644 (file)
@@ -15,7 +15,7 @@ class Admin::OrdersController < Admin::BaseController
   end
 
   def edit
-    order_delivery = OrderDelivery.find_by_order_id(params[:id])
+    order_delivery = OrderDelivery.find_by_order_id(params[:id].to_i)
     raise ActiveRecord::RecordNotFound if order_delivery.nil? || order_delivery.order.retailer_id != session[:admin_user].retailer_id
     if params[:recalculate]
       recalculate
@@ -25,7 +25,7 @@ class Admin::OrdersController < Admin::BaseController
       update
       return
     end
-    @order_delivery = OrderDelivery.find_by_order_id(params[:id])
+    @order_delivery = OrderDelivery.find_by_order_id(params[:id].to_i)
     @order_delivery_ticket = @order_delivery.ticket_code
     select_delivery_time
   end
@@ -40,7 +40,7 @@ class Admin::OrdersController < Admin::BaseController
 
   def update
     get_order_delivery
-    #@order_delivery = OrderDelivery.find_by_order_id(params[:id])
+    #@order_delivery = OrderDelivery.find_by_order_id(params[:id].to_i)
     if @order_delivery.nil? || @order_delivery.order.retailer_id != session[:admin_user].retailer_id
       raise ActiveRecord::RecordNotFound
     end
@@ -53,7 +53,7 @@ class Admin::OrdersController < Admin::BaseController
         redirect_to :action => 'index'
       end
     rescue => e
-      @order_delivery = OrderDelivery.find_by_order_id(params[:id])
+      @order_delivery = OrderDelivery.find_by_order_id(params[:id].to_i)
       @order_delivery_ticket = @order_delivery.ticket_code
       select_delivery_time
       flash.now[:error] = "保存に失敗しました"
@@ -63,7 +63,7 @@ class Admin::OrdersController < Admin::BaseController
 
   def destroy
     # 親と子も消す
-    order_delivery = OrderDelivery.find(:first, :conditions => ["order_id=?", params[:id]])
+    order_delivery = OrderDelivery.find(:first, :conditions => ["order_id=?", params[:id].to_i])
     begin
       raise if order_delivery.nil? || order_delivery.order.retailer_id != session[:admin_user].retailer_id
       order_delivery.order_details.each(&:destroy)
@@ -110,7 +110,7 @@ class Admin::OrdersController < Admin::BaseController
   end
 
   def get_order_delivery
-    @order_delivery = OrderDelivery.find_by_order_id(params[:id])
+    @order_delivery = OrderDelivery.find_by_order_id(params[:id].to_i)
     @order_delivery.attributes = params[:order_delivery]
   end
 
index cacf0e0..78143ed 100644 (file)
@@ -16,18 +16,18 @@ class Admin::PluginsController < Admin::BaseController
 
   def edit_payment_plugin
     unless params[:id].blank?
-      @payment_plugin = PaymentPlugin.find_by_id(params[:id])
+      @payment_plugin = PaymentPlugin.find_by_id(params[:id].to_i)
     end
     unless params[:payment_plugin].blank?
-      @payment_plugin = PaymentPlugin.find_by_id(params[:payment_plugin][:id])
+      @payment_plugin = PaymentPlugin.find_by_id(params[:payment_plugin][:id].to_i)
       @payment_plugin.attributes = params[:payment_plugin]
-      params[:id] = params[:payment_plugin][:id]
+      params[:id] = params[:payment_plugin][:id].to_i
     end
     redirect_to :action => "index" if @payment_plugin.nil?
   end
 
   def confirm_payment_plugin
-    @payment_plugin = PaymentPlugin.find_by_id(params[:id]) || PaymentPlugin.new
+    @payment_plugin = PaymentPlugin.find_by_id(params[:id].to_i) || PaymentPlugin.new
     @payment_plugin.attributes = params[:payment_plugin]
     unless @payment_plugin.valid?
       if params[:id].blank? and params[:payment_plugin][:id].blank?
@@ -48,7 +48,7 @@ class Admin::PluginsController < Admin::BaseController
   end
 
   def edit_payment_plugin_config
-    @payment_plugin = PaymentPlugin.find_by_id(params[:id])
+    @payment_plugin = PaymentPlugin.find_by_id(params[:id].to_i)
     if @payment_plugin.nil?
       redirect_to(:action => :index)
       return
@@ -67,7 +67,7 @@ class Admin::PluginsController < Admin::BaseController
   end
 
   def payment_plugin_data_management
-    unless get_plugin_instance(params[:id])
+    unless get_plugin_instance(params[:id].to_i)
       flash[:notice] = "このプラグインのインスタンスが取得できません。無効になっているか確認してください。"
       redirect_to(:action => :index)
       return
@@ -82,7 +82,7 @@ class Admin::PluginsController < Admin::BaseController
   end    
 
   def payment_plugin_config
-    unless get_plugin_instance(params[:id], true)
+    unless get_plugin_instance(params[:id].to_i, true)
       flash.now[:notice] = "このプラグインのインスタンスが取得できません。無効になっているか確認してください。"
       redirect_to(:action => :index)
       return
@@ -97,7 +97,7 @@ class Admin::PluginsController < Admin::BaseController
   end
 
   def payment_plugin_info
-    unless get_plugin_instance(params[:id], true)
+    unless get_plugin_instance(params[:id].to_i, true)
       flash.now[:notice] = "このプラグインのインスタンスが取得できません。クラスが正しく設定されているか確認してください。"
       redirect_to(:action => :index)
       return
@@ -130,7 +130,7 @@ class Admin::PluginsController < Admin::BaseController
       @payment_plugin = PaymentPlugin.new(params[:payment_plugin])
     elsif type == :update
       back_to = :edit_payment_plugin
-      @payment_plugin = PaymentPlugin.find_by_id(params[:payment_plugin][:id])
+      @payment_plugin = PaymentPlugin.find_by_id(params[:payment_plugin][:id].to_i)
       @payment_plugin.attributes = params[:payment_plugin]
     else
       raise "不正な遷移"
index 9f4410a..32a12ce 100644 (file)
@@ -1,15 +1,16 @@
+# -*- coding: utf-8 -*-
 class Admin::ProductStylesController < Admin::BaseController
   before_filter :admin_permission_check_product,
     :only => [:create, :new]
   
   def new
-    @product = Product.find_by_id(params[:id])
-    set_product_styles(params[:id])
+    @product = Product.find_by_id(params[:id].to_i)
+    set_product_styles(params[:id].to_i)
     set_style_category
   end
 
   def create_form
-    @product = Product.find_by_id(params[:id])
+    @product = Product.find_by_id(params[:id].to_i)
     set_style_category
     if @style1.nil? && ! @style2.nil?
       @error_message = "規格1が無い状態で規格 2を登録出来ません。"
@@ -47,7 +48,7 @@ class Admin::ProductStylesController < Admin::BaseController
   
   #在庫管理履歴プレビュー
   def stock_histories
-    product_style_id = params[:id]
+    product_style_id = params[:id].to_i
     if !product_style_id.blank? && product_style_id=~ /^\d*$/
       @product_style = ProductStyle.find_by_id(product_style_id.to_i)
       if !@product_style.blank?
@@ -63,8 +64,8 @@ class Admin::ProductStylesController < Admin::BaseController
   def set_style_category
     @product_product_styles ||= []
     if params[:style_id1]
-      @style1 = Style.find_by_id(params[:style_id1]) unless params[:style_id1].blank?
-      @style2 = Style.find_by_id(params[:style_id2]) unless params[:style_id2].blank?
+      @style1 = Style.find_by_id(params[:style_id1].to_i) unless params[:style_id1].blank?
+      @style2 = Style.find_by_id(params[:style_id2].to_i) unless params[:style_id2].blank?
       if @product_product_styles.blank?
         @product.product_styles.each do | p_s |
           @product_product_styles << p_s
@@ -94,7 +95,7 @@ class Admin::ProductStylesController < Admin::BaseController
     end
   end
 
-  def set_product_styles(id = params[:product_id])
+  def set_product_styles(id = params[:product_id].to_i)
     @product = Product.find_by_id(id)
     if params[:product_styles]
       @product_styles = []
index 084c2f5..29e112c 100644 (file)
@@ -31,7 +31,7 @@ class Admin::ProductsController < Admin::BaseController
     get_product_status_by_params
     get_sub_product_by_params
     if params[:copy]
-      @old_product = Product.find_by_id(params[:id])
+      @old_product = Product.find_by_id(params[:id].to_i)
       @old_product.id = nil
       params[:id] = nil
       @product = Product.new @old_product.attributes.reject{ |key, value| key.to_s == "id" }
@@ -64,7 +64,7 @@ class Admin::ProductsController < Admin::BaseController
   edit.before do
     get_product
 
-    @product_statuses = ProductStatus.find(:all, :conditions=>["product_id=?", params[:id]])
+    @product_statuses = ProductStatus.find(:all, :conditions=>["product_id=?", params[:id].to_i])
     get_sub_product_by_params
     get_product_status_by_params
   end
index 0d17d69..deae53f 100644 (file)
@@ -13,7 +13,7 @@ class Admin::ServiceCooperationsController < Admin::BaseController
   end
 
   def edit
-    @service_cooperation = ServiceCooperation.find_by_id(params[:id])
+    @service_cooperation = ServiceCooperation.find_by_id(params[:id].to_i)
     if @service_cooperation.nil?
       flash[:notice] = '無効なidが渡されました'
       redirect_to :action => "index"
@@ -21,7 +21,7 @@ class Admin::ServiceCooperationsController < Admin::BaseController
   end
 
   def get_template_ajax
-    template_id = params[:id]
+    template_id = params[:id].to_i
     unless template_id.blank?
       service_template = ServiceCooperationsTemplate.find_by_id(template_id)
       unless service_template.nil?
@@ -50,7 +50,7 @@ class Admin::ServiceCooperationsController < Admin::BaseController
   end
 
   def confirm
-    @service_cooperation = ServiceCooperation.find_by_id(params[:id]) || ServiceCooperation.new
+    @service_cooperation = ServiceCooperation.find_by_id(params[:id].to_i) || ServiceCooperation.new
     @service_cooperation.attributes = params[:service_cooperation]
 
     unless @service_cooperation.valid?
@@ -75,7 +75,7 @@ class Admin::ServiceCooperationsController < Admin::BaseController
   end
 
   def update
-    @service_cooperation = ServiceCooperation.find_by_id(params[:id])
+    @service_cooperation = ServiceCooperation.find_by_id(params[:id].to_i)
     @service_cooperation.attributes = params[:service_cooperation]
     if @service_cooperation.save
       flash[:notice] = 'サービスは正常に更新されました'
@@ -87,7 +87,7 @@ class Admin::ServiceCooperationsController < Admin::BaseController
   end
 
   def destroy
-    service = ServiceCooperation.find_by_id(params[:id])
+    service = ServiceCooperation.find_by_id(params[:id].to_i)
     if service
       service.destroy
     else
index 3057d61..42f05a5 100644 (file)
@@ -11,7 +11,7 @@ class Admin::ServiceCooperationsTemplatesController < Admin::BaseController
   end
 
   def edit
-    @service_cooperations_template = ServiceCooperationsTemplate.find_by_id(params[:id])
+    @service_cooperations_template = ServiceCooperationsTemplate.find_by_id(params[:id].to_i)
     if @service_cooperations_template.nil?
       flash[:notice] = '無効なidが渡されました'
       redirect_to :action => 'index'
@@ -19,7 +19,7 @@ class Admin::ServiceCooperationsTemplatesController < Admin::BaseController
   end
 
   def confirm
-    @service_cooperations_template = ServiceCooperationsTemplate.find_by_id(params[:id]) || ServiceCooperationsTemplate.new
+    @service_cooperations_template = ServiceCooperationsTemplate.find_by_id(params[:id].to_i) || ServiceCooperationsTemplate.new
     @service_cooperations_template.attributes = params[:service_cooperations_template]
     unless @service_cooperations_template.valid?
       if params[:id].blank?
@@ -44,7 +44,7 @@ class Admin::ServiceCooperationsTemplatesController < Admin::BaseController
   end
 
   def update
-    @service_cooperations_template = ServiceCooperationsTemplate.find_by_id(params[:id])
+    @service_cooperations_template = ServiceCooperationsTemplate.find_by_id(params[:id].to_i)
     @service_cooperations_template.attributes = params[:service_cooperations_template]
     if @service_cooperations_template.save
       flash[:notice] = 'テンプレートは正常に更新されました'
@@ -56,7 +56,7 @@ class Admin::ServiceCooperationsTemplatesController < Admin::BaseController
   end
 
   def destroy
-    service_template = ServiceCooperationsTemplate.find_by_id(params[:id])
+    service_template = ServiceCooperationsTemplate.find_by_id(params[:id].to_i)
     if service_template
       service_template.destroy
     else
index a7937bd..44ae23d 100644 (file)
@@ -66,7 +66,7 @@ class Admin::ShopsController < Admin::BaseController
   end
 
   def delivery_edit
-    @delivery_trader = DeliveryTrader.find(params[:id])
+    @delivery_trader = DeliveryTrader.find(params[:id].to_i)
     @delivery_time = @delivery_trader.delivery_times
     @delivery_fee = @delivery_trader.delivery_fees
   end
@@ -115,7 +115,7 @@ class Admin::ShopsController < Admin::BaseController
   end
 
   def delivery_update
-    @delivery_trader = DeliveryTrader.find(params[:id])
+    @delivery_trader = DeliveryTrader.find(params[:id].to_i)
     @delivery_time = @delivery_trader.delivery_times
     @delivery_fee =@delivery_trader.delivery_fees
     DeliveryTime::MAX_SIZE.times do |index|
@@ -139,7 +139,7 @@ class Admin::ShopsController < Admin::BaseController
     DeliveryTrader.transaction do
       if @delivery_trader.delivery_times << @delivery_time && @delivery_trader.delivery_fees << @delivery_fee&& @delivery_trader.save
         flash.now[:notice] = "データを保存しました"
-        redirect_to :action => "delivery_index",:id=>params[:id]
+        redirect_to :action => "delivery_index",:id=>params[:id].to_i
       else
         flash.now[:error] = "保存に失敗しました"
         render :action => "delivery_edit"
@@ -189,7 +189,7 @@ class Admin::ShopsController < Admin::BaseController
   end
 
   def payment_edit
-    @payment = Payment.find(params[:id])
+    @payment = Payment.find(params[:id].to_i)
     if !@payment.id
       flash.now[:error] = "該当するデータがありませんでした"
       redirect_to :action=>:payment_new
@@ -214,7 +214,7 @@ class Admin::ShopsController < Admin::BaseController
   end
 
   def payment_update
-    @payment = Payment.find(params[:id])
+    @payment = Payment.find(params[:id].to_i)
     @payment.attributes = params[:payment]
     set_payment_resource_old
     unless @payment.valid?
@@ -336,7 +336,7 @@ class Admin::ShopsController < Admin::BaseController
   def kiyaku_index
     kiyaku_list
     if params[:id]
-      @kiyaku = Kiyaku.find_by_id(params[:id])
+      @kiyaku = Kiyaku.find_by_id(params[:id].to_i)
     else
       @kiyaku = Kiyaku.new
     end
@@ -362,7 +362,7 @@ class Admin::ShopsController < Admin::BaseController
   end
 
   def kiyaku_update
-    @kiyaku = Kiyaku.find(params[:kiyaku][:id])
+    @kiyaku = Kiyaku.find(params[:kiyaku][:id].to_i)
     @kiyaku.attributes = params[:kiyaku]
     unless @kiyaku.valid?
       kiyaku_list
index 5b7d4a3..d2b2a65 100644 (file)
@@ -3,23 +3,27 @@ class Admin::StyleCategoriesController < Admin::BaseController
 
   index.before do
     @style_categories = StyleCategory.find(:all, 
-                                           :conditions => ["style_id = ?", params[:style_id]],
+                                           :conditions => ["style_id = ?", params[:style_id].to_i],
                                            :order => "position")
-    @style_category = StyleCategory.find_by_id(params[:id]) || StyleCategory.new({:style_id=>params[:style_id]})
+    @style_category = StyleCategory.find_by_id(params[:id].to_i) || StyleCategory.new({:style_id=>params[:style_id]})
   end
 
   new_action.wants.html do
-    redirect_to :action => "index", :style_id => params[:style_id]
+    if params[:style_id].to_i != 0
+      redirect_to :action => "index", :style_id => params[:style_id].to_i 
+    else
+      redirect_to :action => "index"
+    end
   end
 
   [create, update, destroy].each do |action|
     action.wants.html do
-      redirect_to :action => "index", :style_id => params[:style_id]
+      redirect_to :action => "index", :style_id => params[:style_id].to_i
     end
 
     action.failure.wants.html do
       @style_categories = StyleCategory.find(:all, 
-                                             :conditions => ["style_id = ?", params[:style_id]],
+                                             :conditions => ["style_id = ?", params[:style_id].to_i],
                                              :order => "position")
       render :action => "index"
     end
@@ -27,21 +31,21 @@ class Admin::StyleCategoriesController < Admin::BaseController
 
   def up
     super
-    redirect_to :action => :index, :style_id => params[:style_id]
+    redirect_to :action => :index, :style_id => params[:style_id].to_i
   end
 
   def down
     super
-    redirect_to :action => :index, :style_id => params[:style_id]
+    redirect_to :action => :index, :style_id => params[:style_id].to_i
   end
 
   private
   def object
     if not params[:id].blank?
-      style_category = StyleCategory.find_by_id(params[:id])
+      style_category = StyleCategory.find_by_id(params[:id].to_i)
       raise ActiveRecord::RecordNotFound unless style_category.style.retailer_id == session[:admin_user].retailer_id
     elsif params[:style_category] && params[:style_category][:style_id]
-      style = Style.find(:all, :conditions => ["id = ? and retailer_id = ? ", params[:style_category][:style_id], session[:admin_user].retailer_id])
+      style = Style.find(:all, :conditions => ["id = ? and retailer_id = ? ", params[:style_category][:style_id].to_i, session[:admin_user].retailer_id])
       raise ActiveRecord::RecordNotFound if style.nil? or style == []
     end
     super
index 2f2eaf7..816b5d8 100644 (file)
@@ -4,7 +4,7 @@ class Admin::StylesController < Admin::BaseController
   
   index.before do
     @styles = Style.find(:all, :conditions=>["retailer_id = ? ", session[:admin_user].retailer_id], :order => "position")
-    @style = Style.find(:last, :conditions=>["id = ? and retailer_id = ? ", params[:id], session[:admin_user].retailer_id]) || Style.new
+    @style = Style.find(:last, :conditions=>["id = ? and retailer_id = ? ", params[:id].to_i, session[:admin_user].retailer_id]) || Style.new
   end
   
   new_action.wants.html do
@@ -34,7 +34,7 @@ class Admin::StylesController < Admin::BaseController
 
   private
   def object
-    @object ||= Style.find(:last, :conditions => ["id = ? and retailer_id = ? ", params[:id], session[:admin_user].retailer_id])
+    @object ||= Style.find(:last, :conditions => ["id = ? and retailer_id = ? ", params[:id].to_i, session[:admin_user].retailer_id])
   end
 
 end
index 2709a30..01cc141 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 class Admin::SuppliersController < Admin::BaseController
   #共通
   resource_controller
@@ -74,7 +75,7 @@ class Admin::SuppliersController < Admin::BaseController
   end
   private
   def get_supplier
-      @supplier = Supplier.find_by_id(params[:id])
+      @supplier = Supplier.find_by_id(params[:id].to_i)
       @supplier.attributes = params[:supplier]    
   end  
 end
index dd76aa8..1db272c 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 class CampaignsController < BaseController
   before_filter :login_check, :only => [:complete, :show]
   def show
@@ -42,7 +43,7 @@ class CampaignsController < BaseController
 
   #応募人数の更新とcampaign_entryにレコードを追加
   def complete
-    @id = params[:id]
+    @id = params[:id].to_i
     @campaign = Campaign.find(@id)
     @campaign.application_count = 0 if @campaign.application_count.blank?
 
index c83b55b..8cb554f 100644 (file)
@@ -515,7 +515,7 @@ class CartController < BaseController
     @carts ||= []
     product_style =
       if params[:product_style_id]
-        ProductStyle.find_by_id(params[:product_style_id])
+        ProductStyle.find_by_id(params[:product_style_id].to_i)
       else
         ProductStyle.find_by_product_id_and_style_category_id1_and_style_category_id2(params[:product_id], params[:style_category_id1], params[:style_category_id2])
       end
index cd62cd7..61e520e 100644 (file)
@@ -7,7 +7,7 @@ class ImageResourceController < BaseController
       @res = ImageResource.find_by_name(params[:filename])
     end
     if params[:id]
-      @res ||= ImageResource.find_by_id(params[:id])
+      @res ||= ImageResource.find_by_id(params[:id].to_i)
     end
     raise ActiveRecord::RecordNotFound unless @res
     if request.mobile?
index aae3437..241db0d 100644 (file)
@@ -12,7 +12,7 @@ class PortalController < BaseController
 
   def show_tradelaw
     if params[:retailer_id]
-      @law = Law.find_by_retailer_id(params[:retailer_id])
+      @law = Law.find_by_retailer_id(params[:retailer_id].to_i)
     end
     unless @law
       @law = Law.find_by_retailer_id(Retailer::DEFAULT_ID)
index 9ea7504..6714c52 100644 (file)
@@ -59,7 +59,7 @@ class ProductsController < BaseController
 
   def show_image
     unless params[:id].blank?
-      @product = Product.find(:first, :conditions => ["products.id = ? and permit = ? and ? >= products.sale_start_at",  params[:id], true, Date.today],
+      @product = Product.find(:first, :conditions => ["products.id = ? and permit = ? and ? >= products.sale_start_at",  params[:id].to_i, true, Date.today],
                               :include => Product::DEFAULT_INCLUDE)
     end
     render :layout => false
@@ -81,7 +81,7 @@ class ProductsController < BaseController
   private
   def load_product
     unless params[:id].blank?
-      @product = Product.find(:first, :conditions => ["products.id = ? and permit = ? and ? >= products.public_start_at",  params[:id], true, Date.today],
+      @product = Product.find(:first, :conditions => ["products.id = ? and permit = ? and ? >= products.public_start_at",  params[:id].to_i, true, Date.today],
                               :include => Product::DEFAULT_INCLUDE)
     end
     if @product
index c4f8006..31b9a45 100644 (file)
@@ -1,4 +1,4 @@
-#class QuestionnairesController < ApplicationController
+# -*- coding: utf-8 -*-
 class QuestionnairesController < BaseController
   before_filter :get_questionnaire
 
@@ -113,8 +113,8 @@ class QuestionnairesController < BaseController
   #アンケートを取得
   def get_questionnaire
     begin
-      @questionnaire = Questionnaire.find(params[:id])
-      @questions = Question.find(:all, :conditions=>["questionnaire_id=? and content is not null and question_choice_id <> 0", params[:id]], :order=>"position")
+      @questionnaire = Questionnaire.find(params[:id].to_i)
+      @questions = Question.find(:all, :conditions=>["questionnaire_id=? and content is not null and question_choice_id <> 0", params[:id].to_i], :order=>"position")
     rescue
       false
     end
index bd7d0ac..0d2d556 100644 (file)
@@ -4,11 +4,11 @@ class RetailersController < BaseController
       redirect_to :controller => :portal, :action => :show
       return
     end
-    @retailer = Retailer.find_by_id(params[:id])
+    @retailer = Retailer.find_by_id(params[:id].to_i)
     unless @retailer
       redirect_to :controller => :portal, :action => :show
       return
     end
-    @delivery_traders = DeliveryTrader.find(:all, :conditions => ["retailer_id = ?", params[:id]])
+    @delivery_traders = DeliveryTrader.find(:all, :conditions => ["retailer_id = ?", params[:id].to_i])
   end
 end
index 85d7f53..d4ae74a 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 require File.dirname(__FILE__) + '/../../spec_helper'
 
 describe Admin::CampaignsController do
@@ -75,6 +76,11 @@ describe Admin::CampaignsController do
       get 'csv_download', :id => 1
       response.headers['Content-Type'].should =~ %r(^application/octet-stream)
     end
+    
+    it "should raise error" do
+      lambda { get 'csv_download', :id => 0 }.should raise_error(ActiveRecord::RecordNotFound)
+    end
+
   end
 
   describe "POST 'campaign_design'" do
index da01d8e..72809b1 100644 (file)
@@ -64,7 +64,7 @@ describe Admin::NewInformationsController do
       assigns[:new_information].id.should == new_informations(:success_validates_2).id
       assigns[:new_information].date.should == DateTime.parse("2008-01-01")
       #assigns[:status].should == "confirm"
-      response.should redirect_to("admin/new_informations")
+      response.should redirect_to(:action => :index)
     end
 
     it "recordのvalidateが通らなかったらstatusはupdateになる" do
@@ -163,6 +163,11 @@ describe Admin::NewInformationsController do
     it "編集画面に遷移できない場合" do
       lambda { get 'edit', :id => 100 }.should raise_error(ActiveRecord::RecordNotFound)
     end
+
+    it "new_informationに不正な値をいれてみるとエラーになる" do
+      lambda { get 'edit', :id => 1, :new_information => {"id" => "0", "date" => "2009-11-13 15:42:00 +0900", "name" => 'test', "new_window" => 0, "body" => ''} }.should raise_error(ActiveRecord::RecordNotFound)
+    end
+
   end
 
   describe "POST 'confirm'" do
index d4a6da4..c0cb208 100644 (file)
@@ -186,7 +186,7 @@ describe Admin::ServiceCooperationsController do
   describe "GET 'destroy'" do
     it "レコードが1つ減ったか" do
       services_length = (ServiceCooperation.all).length
-      get 'destroy', :id => service_cooperations(:one)
+      get 'destroy', :id => service_cooperations(:one).id
       services_length.should == (ServiceCooperation.all).length + 1
     end
     it "意図したレコードが削除されたか" do
index 2ac36c6..1c36e90 100644 (file)
@@ -188,12 +188,12 @@ describe Admin::ServiceCooperationsTemplatesController do
     end
     it "レコードが1つ減ったか" do
       services_length = (ServiceCooperationsTemplate.all).length
-      get 'destroy',:id => service_cooperations_templates(:one)
+      get 'destroy',:id => service_cooperations_templates(:one).id
       services_length.should == (ServiceCooperationsTemplate.all).length + 1
     end
     it "意図したレコードが削除されたか" do
       ServiceCooperationsTemplate.find_by_id(service_cooperations_templates(:one)).should_not be_nil
-      get 'destroy',:id => service_cooperations_templates(:one)
+      get 'destroy',:id => service_cooperations_templates(:one).id
       ServiceCooperationsTemplate.find_by_id(service_cooperations_templates(:one)).should be_nil
     end
     it "無効なidの場合はレコード数は増減しない" do
@@ -223,7 +223,7 @@ def service_cooperations_template_new_before_do
 end
 
 def service_cooperations_template_edit_before_do
-  get 'edit', :id => service_cooperations_templates(:one)
+  get 'edit', :id => service_cooperations_templates(:one).id
   @service_template = assigns[:service_cooperations_template]
   @service_template.template_name = 'test_update_template'
   @service_template.description = '設定'