Welcome to Working With Rails


Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
5 Posts
Month View

Hello guys, I was wondering if someone can help with this. 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

So I want to be able to see the trips in a month view like here http://www.pogdesign.co.uk/cat/ , just instead of tv shows it will display my trips, based on load_on. Also I am using the resource controller: http://jamesgolick.com/resource_controller and that doesn't make it easier. Can someone help please.

Hi Michael,

Your question is fairly vague. Can you provide more details? What have you tried to do so far to achieve your goal? Are there certain areas in particular you are having trouble with?

--Chris Blackburn

Hey Chris, what I want is let's say when I go to http://localhost/trips/ I would see them in a calendar view like on the website I wrote above. Depending on the trip.load_on, trips would be arranged in each day of the month.


While I love resource_controller and think its a fantastically DRY way to deal with your controllers, I would personally recommend that you wait until you have a better grasp of RESTful controllers. It was helpful for me in the beginning to always see those seven actions in place and now how they were working inside of the code.

Your solution is going to be in actually programatically creating a view that renders a month view and the information inside of each of them. It is perhaps a slightly more complicated view than your standard issue view, but is far from impossible.

I'm not going to just solve your problem here, but what I recommend you read up on is how to use code blocks in Ruby. This should then give you some ideas of how to a systematic way to produce a month view. If you want some help refactoring your code after you've produced something I'm sure myself and others on here would be happy to give you some pointers on how you might make it cleaner. Remember, Fat models, slim controllers, and skinny views. So try and keep as much of that sort of logic as you can into your models, and then let it trickle down to controllers and then views.

Hope that helps, and sorry I can't point you to a fancy plugin that will do it all for you, but if you're just starting you'd probably be best try and struggle through creating this sort of thing yourself, and then, creating a plugin from it.

Good luck!

Hi Michael,

Please have a look at "Calender helper written by Jeremy Voorhis":http://topfunky.net/svn/plugins/calendar_helper/

I am not sure if you can get exactly the same UI as in the link you posted but I am pretty sure it's easy to extend this helper (css) as per the needs. A basic example for this helper can be found at "Ruby on Rails Workshops calendar":http://rubyonrailsworkshops.com/

Please rate me if you find this post helpful.

  • Chetan Mittal.
5 Posts
Login to add your message