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
@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
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')
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
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
+# -*- coding: utf-8 -*-
class Admin::AdminUsersController < Admin::BaseController
resource_controller
before_filter :admin_permission_check_member
[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"
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
#稼働/非稼働チェック(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"
+# -*- coding: utf-8 -*-
class Admin::AuthoritiesController < Admin::BaseController
#共通
resource_controller
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"
+# -*- coding: utf-8 -*-
class Admin::BaseController < ApplicationController
before_filter :load_system
before_filter :load_admin
}
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
+# -*- coding: utf-8 -*-
require 'kconv'
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)
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)
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?
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)
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
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
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
+# -*- coding: utf-8 -*-
class Admin::FeatureProductsController < Admin::BaseController
#共通
resource_controller
#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
#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
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
+# -*- coding: utf-8 -*-
class Admin::FeaturesController < Admin::BaseController
#共通
resource_controller
#確認画面
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])
+# -*- coding: utf-8 -*-
class Admin::MailMagazineTemplatesController < Admin::BaseController
resource_controller
mobile_filter
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
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)
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")
#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
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
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
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
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] = "保存に失敗しました"
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)
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
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?
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
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
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
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
@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 "不正な遷移"
+# -*- 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を登録出来ません。"
#在庫管理履歴プレビュー
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?
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
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 = []
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" }
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
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"
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?
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?
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] = 'サービスは正常に更新されました'
end
def destroy
- service = ServiceCooperation.find_by_id(params[:id])
+ service = ServiceCooperation.find_by_id(params[:id].to_i)
if service
service.destroy
else
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'
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?
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] = 'テンプレートは正常に更新されました'
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
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
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|
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"
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
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?
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
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.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
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.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
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
+# -*- coding: utf-8 -*-
class Admin::SuppliersController < Admin::BaseController
#共通
resource_controller
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
+# -*- coding: utf-8 -*-
class CampaignsController < BaseController
before_filter :login_check, :only => [:complete, :show]
def show
#応募人数の更新と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?
@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
@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?
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)
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
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
-#class QuestionnairesController < ApplicationController
+# -*- coding: utf-8 -*-
class QuestionnairesController < BaseController
before_filter :get_questionnaire
#アンケートを取得
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
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
+# -*- coding: utf-8 -*-
require File.dirname(__FILE__) + '/../../spec_helper'
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
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
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
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
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
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 = '設定'