Rob’s Reminders r7

Major:

Added a new action to the reminders controller.

I added a new method and view to my reminders controller to show completed items.

In Reminders Controller I added

def completed
@reminders = Reminder.find(:all, :conditions => [ "done = ? and user_id = ?", true, current_user.id])
end

I also added completed.html.erb to the views for reminders. However when I accessed the /reminders/completed url I got an error message.

ActiveRecord::RecordNotFound in RemindersController#show

WTF? Why is the error in show? Well after a half hour or cursing rails I figured it out.

In the routes.rb file you will see a line

map.resources :reminders

What this does is add mappings for index, edit, create, show. With everything other then index, edit, create assigned to show.

You have to add a mapping for your new method to get around this.

map.connect 'reminders/completed', :controller => 'reminders', :action => 'completed'
map.resources :reminders

Now you can try the completed method, and it will work.

Minor changes:

Changed title, added Calendar control to created reminders.

Also robsreminders.com is finally up and running. Thanks to dream host. They are now running rails 2.0.2, and where a ton of help. I recommend them if you are looking for a rails host.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *