ruby - Rails array help - How to order an array after date -


i trying sort array after dato(date).

i have tried without luck:

<%= reklamer.where(:name => 'orville', :order => 'dato asc').all.map(&:earn) %> 

and this:

<%= reklamer.where(:name => 'orville').all.map(&:earn).order('dato asc') %> 

and:

<%= reklamer.where(:name => 'orville').order('dato asc').all.map(&:earn) %> 

and:

<%= reklamer.where(:name => 'orville').all.order('dato asc').map(&:earn) %> 

try this:

<%= reklamer.where(:name => 'orville').order('dato asc').map(&:earn).join(', ') %> 

though in general, recommend not putting data loading code view. instead, push models , controllers. example, in controller:

def show   @earnings = reklamer.where(:name => 'orville').order('dato asc').map(&:earn) end 

or, better, push of more complicated stuff model:

class reklamer   def self.earnings     where(:name => 'orville').order('dato asc').map(&:earn)   end end 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -