2011-08-18 1 views
1

Je suis perdu sur la façon de rendre ce rendu partiel. il remplace une structure identitaire dans <table id="tab">. S'il vous plaît laissez-moi savoir si ce n'est pas assez d'informations.Appel de deux méthodes dans le contrôleur/modèle manquant

erreur

Started GET "/p_sort" for 127.0.0.1 at 2011-08-18 12:35:42 -0500 
    Processing by AnalyticsController#p_sort as JS 
Completed 500 Internal Server Error in 5ms 

ActionView::MissingTemplate (Missing template analytics/p_sort, application/p_sort with {:handlers=>[:erb, :builder, :coffee, :haml], :formats=>[:js, :html], :locale=>[:en, :en]}. Searched in: 
    * "/Users/jess/Sites/shares/app/views" 
): 
    app/controllers/analytics_controller.rb:435:in `tsort' 
    app/controllers/analytics_controller.rb:428:in `p_sort' 

contrôleur

def p_sort 
    column = lambda { |a,b| a.percentage <=> b.percentage } 
    tsort(column, :reverse) 
    end 

    def tsort(column, direction = :forward) 
    @holdings = session[:holdings] 
    @holdings = @holdings.sort! &column 
    direction == :reverse ? @holdings = @holdings.reverse! : nil 
    respond_to do |format| 
     format.js 
    end 
    end 

tsort.js.erb

jQuery('#tab').html("<%= escape_javascript(render(:partial => 'tsort')) %>"); 

_tsort.html.erb

<tr> 
    <th><%= link_to('name', '/n_sort', remote: true, class: 'analytics_captable') %></th> 
    <th><%= link_to('security', '/s_sort', remote: true, class: 'analytics_captable') %></th> 
    <th><%= link_to('dollars', '/d_sort', remote: true, class: 'analytics_captable') %></th> 
    <th><%= link_to('shares', '/sh_sort', remote: true, class: 'analytics_captable') %></th> 
    <th><%= link_to('percentage', '/p_sort'}, remote: true, class: 'analytics_captable') %></th> 
    <th>transactions</th> 
    </tr> 
    <% @holdings.each do |holding| %> 
    <tr> 
    <td><%= holding.name %></td> 
    <td><%= holding.security %></td> 
    <td><%= number_to_currency holding.dollars %></td> 
    <td><%= number_with_delimiter holding.shares %></td> 
    <td><%= number_to_percentage(holding.percentage, :precision => 2) %></td> 
    <td><%= link_to :details, "/entities/#{holding.entity_id}" %></td> 
    </tr> 
    <% end %> 

Répondre

0

Contrôleur

def p_sort 
    column = lambda { |a,b| a.percentage <=> b.percentage } 
    @holdings = session[:holdings] 
    @holdings = @holdings.sort! &column 
    @holdings.reverse! 
    respond_to do |format| 
     format.js { render 'tsort' } 
    end 
    end 

    def tsort 
    respond_to do |format| 
     format.js 
    end 
    end 
Questions connexes