Michael Gao
2008-Jun-30 03:13 UTC
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 => "testemail-J0of1frlU80@public.gmane.org", :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 } @template 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 Attachments: http://www.ruby-forum.com/attachment/2274/error.JPG -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jun-30 07:57 UTC
Re: undefined method ''view_paths'' for #<Array:0x34568f4>?Realy?
> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Gao
2008-Jul-02 01:15 UTC
Re: undefined method ''view_paths'' for #<Array:0x34568f4>?Realy?
Frederick Cheung 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) > > FredThanks, I know,thank you vary mach -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---