Hey guys need some help, I have a model like this: t.integer :company_id t.string :truck t.string :trailer t.string :driver t.string :from t.date :load_on t.decimal :price and I want to be able to see the trips in a month view like on this website: http://www.pogdesign.co.uk/cat/ I have no idea how to do it, any help would be greatly appreciated. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2008/3/6, Michael Peterson <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Hey guys need some help, I have a model like this: > t.integer :company_id > t.string :truck > t.string :trailer > t.string :driver > t.string :from > t.date :load_on > t.decimal :price > > and I want to be able to see the trips in a month view like on this > website: http://www.pogdesign.co.uk/cat/See: http://wiki.rubyonrails.org/rails/pages/UnderstandingViews You probably want to use tables. HTH, Stefan --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
It''s not about the views it''s the controller I added something
like
this:
[code]start_of_month = Date.today #create a DateTime object that is at
the beginning of the month you are displaying
end_of_month = 31/03/2008 #create a DateTime object that is at the
end of the month you are displaying
@trips = Trip.find(:all, :conditions => ["load_on BETWEEN ? AND
?",
start_of_month, end_of_month]
@trip_days = @trips.group_by { |m| m.load_on.day }[/code]
and then in the view
[code]
@trip_days.sort.each do |day, trips|
day
for trip in trips
trip.truck
end
[/code]
but this doesn''t really work, and I want it to automatically show the
current month.
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
2008/3/6, Michael Peterson <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > It''s not about the views it''s the controller I added something like > this: > [code]start_of_month = Date.today #create a DateTime object that is at > the beginning of the month you are displaying > end_of_month = 31/03/2008 #create a DateTime object that is at the > end of the month you are displaying > @trips = Trip.find(:all, :conditions => ["load_on BETWEEN ? AND ?", > start_of_month, end_of_month] > @trip_days = @trips.group_by { |m| m.load_on.day }[/code] > > and then in the view > [code] > @trip_days.sort.each do |day, trips| > day > for trip in trips > trip.truck > end > [/code] > but this doesn''t really work, and I want it to automatically show the > current month.What does not work? Do you get an exception? No data on the page? Assuming your view is rhtml, it should look more like: <html> more markup blah, blah, blah <% @trip_days.sort.each do |day, trips| %> <%= day %> <% for trip in trips %> <%= trip.truck %> <% end %> <% end %> more markup </html> --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---