# Help with partial

**URL:** <https://www.ruby-forum.com/t/help-with-partial/153665>\
**Category:** Ruby\
**Created:** [November 19, 2008, 11:03pm UTC](https://www.ruby-forum.com/t/help-with-partial/153665 "2008-11-19T23:03:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chimorito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/54ee81/32.png) [@chimorito](https://www.ruby-forum.com/u/chimorito)\
**Post date:** [November 19, 2008, 11:03pm UTC](https://www.ruby-forum.com/t/help-with-partial/153665/1 "2008-11-19T23:03:16Z")

</div>

First and foremost sorry if my english is not the best.

In my application I have a view whit tickets and i can select it one to  
one with a button.  
The selected tickets go to another view that shows me the tickets i have  
choosen. I want to export this selected tickets to excell.

## My code is the next:

## routes.rb

map.resources :tickets, :collection =\> { :exportar=\>:get,  
:auto\_complete\_for\_ticket\_province =\> :get,  
:auto\_complete\_for\_ticket\_city =\> :get,  
:auto\_complete\_for\_ticket\_zip =\> :get,  
:auto\_complete\_for\_ticket\_adquired\_in =\> :get }

* * *

## tickets\_controller

def add\_to\_cartticket  
#Add the selected ticket to cartticket, works fine

end

def find\_cartticket  
#creates a new cartticket if whe iniciates the session, works fine  
end

def vaciar\_cartticket  
#deletes all the tickets added to carticket in the current session,  
works fine  
end

def expotar #THIS METTOD SHOULD SELECT ALL THE CURRENT TICKETS IN  
CARTICKET, i think works wroung  
@cartticket.items= Cartticket.items  
headers[‘Contenet-type’]=“aplication/vnd.ms-excel”  
headers[‘Contenet-Disposition’]=‘attachment; filename=“report.xls”’  
headers[‘Cache-Control’]=’’  
end

* * *

## add\_to\_cartticket.html.erb

h2\>Tickets seleccionados

\<% for item in @cartticket.items %\>- \<%=h item.id %\>
\<% end %\>
  
\<%= button\_to "Vaciar" , :action =\> :vaciar\_cartticket %\>  

\<%= link\_to ‘Exportar a Excel’, exportar\_tickets\_url %\> # MUST SHOW THE  
SELECTED TICKETS ON .XLS COMPATIBLE

* * *

## exportar.html.erb

```
<td>adios</td>

<td>dew</td>

```

 \<%=render :partial=\> "item", :collection=\>@cartticket.items %\> 

| hola |

---------------------------------- exportar.html.erb ---------------------------------- \<%=item.user\_id%\> \<%=item.contact%\> \<%=item.phone%\> 
## 

++++++++++++++++++++++++++++++++++

whe i try to link to “Exportar a Excel” Firefox shows me this error:

NoMethodError in Tickets#exportar

Showing tickets/exportar.html.erb where line #9 raised:

You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.items

Extracted source (around line #9):

6:  
7:

dew  
8:   
9: \<%=render :partial=\> “item”, :collection=\>@cartticket.items %\>  
10: 
* * *

Could somebody help me to find the error(s)…Thanks a lot

---

<div class="post-metadata">

**Author:** ![chimorito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/54ee81/32.png) [@chimorito](https://www.ruby-forum.com/u/chimorito)\
**Post date:** [November 19, 2008, 11:57pm UTC](https://www.ruby-forum.com/t/help-with-partial/153665/2 "2008-11-19T23:57:32Z")

</div>

this should go to the rubyonrails mailing list.

---

<div class="post-metadata">

**Author:** ![chimorito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/54ee81/32.png) [@chimorito](https://www.ruby-forum.com/u/chimorito)\
**Post date:** [November 20, 2008, 12:22am UTC](https://www.ruby-forum.com/t/help-with-partial/153665/3 "2008-11-20T00:22:19Z")

</div>

Ryan D. wrote:

> this should go to the rubyonrails mailing list.

Sorry I move it now
