help with partial

Discussion in 'Ruby' started by Jose vicente Ribera pellicer, Nov 19, 2008.

  1. 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 </h2>
    <ul>
    <% for item in @cartticket.items %>
    <li><%=h item.id %></li>
    <% end %>
    </ul>
    <br/>
    <%= button_to "Vaciar" , :action => :vaciar_cartticket %>
    <br/>

    <%= link_to 'Exportar a Excel', exportar_tickets_url %> # MUST SHOW THE
    SELECTED TICKETS ON .XLS COMPATIBLE



    ------------------------
    exportar.html.erb
    ------------------------
    <table border="1" id="doc">
    <tr>
    <td>hola</td>

    <td>adios</td>

    <td>dew</td>
    </tr>
    <%=render :partial=> "item", :collection=>@cartticket.items %>
    </table>
    ----------------------------------
    exportar.html.erb
    ----------------------------------
    <tr>
    <td> <%=item.user_id%> </td>
    <td> <%=item.contact%> </td>
    <td> <%=item.phone%> </td>

    </tr>
    ----------------------------------
    ++++++++++++++++++++++++++++++++++

    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: <td>dew</td>
    8: </tr>
    9: <%=render :partial=> "item", :collection=>@cartticket.items %>
    10: </table>


    **********************************************

    Could somebody help me to find the error(s).....Thanks a lot
    --
    Posted via http://www.ruby-forum.com/.
     
    Jose vicente Ribera pellicer, Nov 19, 2008
    #1
    1. Advertising

  2. Jose vicente Ribera pellicer

    Ryan Davis Guest

    this should go to the rubyonrails mailing list.
     
    Ryan Davis, Nov 19, 2008
    #2
    1. Advertising

  3. Ryan Davis wrote:
    > this should go to the rubyonrails mailing list.


    Sorry I move it now
    --
    Posted via http://www.ruby-forum.com/.
     
    Jose vicente Ribera pellicer, Nov 19, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Billy
    Replies:
    2
    Views:
    512
    Billy
    Feb 1, 2006
  2. Thomas Heller
    Replies:
    13
    Views:
    864
    Michele Simionato
    Feb 8, 2007
  3. J. Clifford Dyer

    Re: Partial 1.0 - Partial classes for Python

    J. Clifford Dyer, Feb 8, 2007, in forum: Python
    Replies:
    0
    Views:
    525
    J. Clifford Dyer
    Feb 8, 2007
  4. Replies:
    4
    Views:
    322
  5. SAL
    Replies:
    5
    Views:
    2,632
Loading...

Share This Page