Michael Pavling wrote in post #1060114:
> On 9 May 2012 07:34, Ajit Teli <li...@ruby-forum.com> wrote:
>> Currently I am
>> sorting (order) users depending on email id. I would like to sort the
>> users depending on checkbox status so that selected (checked) users will
>> be listed first and then other emails will be listed in the order of
>> email.
>
> The first step is to get that finder out of the view, and move it into
> the User model. Then you can call it on the @current_user instance and
> do all of your sorting and shuffling in one place:
>
> Class User < AR::Base
>   def accessible_users
>     return [] unless role == "excelfore"
>     User.all( :order => :email, :conditions => ( ["role !=
> 'excelfore'"] ) ).sort_by { |u| u.receiving_group_email? }
>   end
>
>   def receiving_group_email?
>     # some calculation here that returns whether or not users are at
> the top of the list - or even better, move it into the conditions of
> the finder...
>   end
> end
>
> # in the view
> <% @current_user.accessible_users.each_with_index do |u,i| %> .... etc


Hi Michael,
Thanks for your reply...

Can I do it by using sorttable.js ? I have included table headers,
sorttable.js. And also I have changed the table class to
class="sortable". But it is not working.

Do I need to give any link to the column headers?

<script src="sorttable.js" type="text/javascript"></script>
<table class="sortable" border="0" cellpadding="2" cellspacing="0">
  <thead>
    <tr>
    <th><%= "Select"%></th>
              <th><%= "Email" %></th>
          <th><%= "Name" %></th>
                </tr>
  </thead>


Thank you,
 Ajit

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to