# Undefined method 'view\_paths' for #\<Array:0x34568f4\>?Realy?

**URL:** <https://www.ruby-forum.com/t/undefined-method-view-paths-for-array-0x34568f4-realy/141723>\
**Category:** Rails\
**Created:** [June 30, 2008, 5:13am UTC](https://www.ruby-forum.com/t/undefined-method-view-paths-for-array-0x34568f4-realy/141723 "2008-06-30T05:13:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgreenly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85f322/32.png) [@mgreenly](https://www.ruby-forum.com/u/mgreenly)\
**Post date:** [June 30, 2008, 5:13am UTC](https://www.ruby-forum.com/t/undefined-method-view-paths-for-array-0x34568f4-realy/141723/1 "2008-06-30T05:13:05Z")

</div>

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 =\> “removed\_email\_address@domain.invalid”,  
: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  
@usereditor.createdman=@user  
@usereditor.updatedman=@user  
@user.usereditor=@usereditor

```
  @bu.users<<@user
  @bu.createdman=@user
  @bu.updatedman=@user

  @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)  
@materialuserdefine.createdman=@user  
@materialuserdefine.updatedman=@user  
@batchuserdefine=Batchuserdefine.new(:columnname=\>“user\_define”

- i.to\_s,:definename=\>“user\_define” + i.to\_s,:datatype\_id=\>1)  
@batchuserdefine.createdman=@user  
@batchuserdefine.updatedman=@user  
i=i+1  
@account.materialuserdefines\<\<@materialuserdefine  
@account.batchuserdefines\<\<@batchuserdefine  
}

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

```
  @coursecodeformat=Coursecodeformat.new()
  @coursecodeformat.createdman=@user
  @coursecodeformat.updatedman=@user
  @account.coursecodeformat = @coursecodeformat

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

```

=\> true )  
@vouchertype.createdman=@user  
@vouchertype.updatedman=@user  
@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

---

<div class="post-metadata">

**Author:** ![mgreenly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85f322/32.png) [@mgreenly](https://www.ruby-forum.com/u/mgreenly)\
**Post date:** [June 30, 2008, 9:57am UTC](https://www.ruby-forum.com/t/undefined-method-view-paths-for-array-0x34568f4-realy/141723/2 "2008-06-30T09:57:59Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![mgreenly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85f322/32.png) [@mgreenly](https://www.ruby-forum.com/u/mgreenly)\
**Post date:** [July 2, 2008, 3:15am UTC](https://www.ruby-forum.com/t/undefined-method-view-paths-for-array-0x34568f4-realy/141723/3 "2008-07-02T03:15:53Z")

</div>

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
