Undefined method 'view_paths' for #<Array:0x34568f4>?Realy?

I write a functional test,here is the code:
require File.dirname(FILE) + ‘/…/test_helper’
require ‘welcome_controller’

Re-raise errors caught by the controller.

class WelcomeController; def rescue_action(e) raise e end; end

class WelcomeControllerTest < Test::Unit::TestCase

fixtures :coursetemplates
fixtures :coursecatalogs
fixtures :currencies
fixtures :states
fixtures :butypes
fixtures :pageformats

def setup
@controller = WelcomeController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end

def test_register
# if register,the controller must create a default bu,
# a default user belong to the bu,ten materialuserdefines,ten
batchmaterialuserdefines,
# a coursecodeexample,a vouchertype and courses accroding to the
coursetemples
post :create, :account => { :name_native => “test account”,
:name_eng => “test account”,
:email => “[email protected]”,
:phone => “testphone”,
:currency_id => 1}
#p @response
assert_response :success
end

def test_login
assert true
end
end

and the function is below:
def create
begin
@account=Account.new(params[:account])

  @bu=Bu.new(:code=>"000",:name_native=>"Manager

Center",:name_eng=>“Manager Center”,:isdefault=>true,:butype_id=>“1”)
@user=User.new(:code=>“admin”,:password=>“groupart”,:isdefault=>true)
@usereditor=Usereditor.new
@[email protected]
@[email protected]r
@[email protected]

  @bu.users<<@user
  @[email protected]
  @[email protected]

  @account.bus<<@bu
  @account.users<<@user

  i=1
  10.times {
    @materialuserdefine=Materialuserdefine.new(:columnname=>"user_define"
  • i.to_s,:definename=>“user_define” + i.to_s,:datatype_id=>1)
    @[email protected]
    @[email protected]
    @batchuserdefine=Batchuserdefine.new(:columnname=>“user_define”

  • i.to_s,:definename=>“user_define” + i.to_s,:datatype_id=>1)
    @[email protected]
    @[email protected]
    i=i+1
    @account.materialuserdefines<<@materialuserdefine
    @account.batchuserdefines<<@batchuserdefine
    }

    @template =
    

Coursetemplate.find(:all,:conditions=>[“coursegrade=1”])
@account.courses << getcoursearray(@template,@user,@account)

  @coursecodeformat=Coursecodeformat.new()
  @[email protected]
  @[email protected]
  @account.coursecodeformat = @coursecodeformat

  @vouchertype=Vouchertype.new(:name_native => 'voucher',:isdefault

=> true )
@[email protected]
@[email protected]
@account.vouchertypes << @vouchertype

  @account.save!

  render :json => {:success => true}.to_json,:layout=>false
rescue Exception => exc
  render :json => {:success =>

false,:errors=>exc.message}.to_json,:layout=>false
end
end

when I run the test,system always told me like below:

  1. Errors:
    test_register(WelcomeControllerTest):
    NoMethodError: undefined method ‘view_paths’ for #Array:0x34568f4

I also upload the error picture

I don’t know why,who can help me.

By the way,I use the extjs, so when I submit a form,I always use the
instrustion like below:
render :json => {:success => true}.to_json,:layout=>false

when I run the test,system always told me like below:

  1. Errors:
    test_register(WelcomeControllerTest):
    NoMethodError: undefined method ‘view_paths’ for #Array:0x34568f4

I also upload the error picture

I don’t know why,who can help me.

Because you have an instance variable called @template (which rails
assumes is something else)

Fred

Frederick C. wrote:

when I run the test,system always told me like below:

  1. Errors:
    test_register(WelcomeControllerTest):
    NoMethodError: undefined method ‘view_paths’ for #Array:0x34568f4

I also upload the error picture

I don’t know why,who can help me.

Because you have an instance variable called @template (which rails
assumes is something else)

Fred

Thanks, I know,thank you vary mach

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs