ruby on rails - Will_paginate inside POST form with nested attributes -


i have 2 models: self-assessment , score, self-assesment has_many :scores , accepts_nested_attributes_for :scores. new self assessment form may have 60 nested scores. implement pagination nested attributes fields inside form.

i tried implement no luck.

controller

def new   @self_assessment = selfassessment.new   @scores = @self_assessment.scores.paginate(:page => params[:page], :per_page => 10, :total_entries=> @self_assessment.scores.size) end 

view

<%= form_for @self_assessment |f| %>     <h2>at home...</h2>     <% category.where(at_home: true).each |category| %>         <h3><%= category.title %></h3>         <% act.where(category_id: category.id).each |act| %>             <%= f.fields_for :scores, score.new |builder| %>                 <%= builder.hidden_field :self_assessment_id, value: @self_assessment.id %>                 <%= builder.select(:rank, scales_for_select(act), prompt: "-select-") %>                 <%= act.name %><br>             <% end %>         <% end %>     <% end %>      <h2>at work...</h2>     <% category.where(at_work: true).each |category| %>         <h3><%= category.title %></h3>         <% act.where(category_id: category.id).each |act| %>             <%= f.fields_for :scores, score.new |builder| %>                 <%= builder.hidden_field :self_assessment_id, value: @self_assessment.id %>                 <%= builder.select(:rank, scales_for_select(act), prompt: "-select-") %>                 <%= act.name %><br>             <% end %>         <% end %>     <% end %>     <%= will_paginate @scores, :params => { :method => :post } %>     <%= f.submit "submit" %> 

i suggest try javascript solutions paginations. try using datatables.

check out link: http://datatables.net/examples/api/form.html

hope helps.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -