I thought that was the case but when I do, I get this error:
Status: 500 Internal Server Error Content-Type: text/html
500 Internal Server Error
Main Topics
Browse All TopicsI want to add a method called delete_all to my controller but defining it there doesn't allow it to be called. What am I doing wrong?
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Here it is:
ActionController::Routing:
map.connect 'pay_periods_controller/de
map.resources :work_schedules
map.resources :daynames
map.resources :phols
map.resources :pay_periods
map.resources :abreviations
map.resources :sections
map.resources :employees
map.resources :programs
map.resources :groups
map.resources :welcomes
map.resources :mains
map.resources :bureaus
map.root :controller => "welcomes"
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:
end
You might try simplifying your code -- maybe using the delete_all method directly, such as the following (this assumes that you don't have any dependent records... destroy actually instantiates the object first and the destroys it, using any callbacks you may have created). delete_all is much more efficient and might make it easier to debug.
It may also have to do with your using a method name which already exists in ActiveRecord, so I've change the name of the method to avoid possible confusion.
You'll have to change your routes to implement this and you'll have to get the related employee id into the condition clause.
HTH...jon
Thanks a lot JESii for your input.
I have no problem deleting all the records in one operation using the Destroy method/action in the controller, the problem is getting the RoR to recognise "delete_all_pay_periods" (in my case delete_all). Everything I do results in the 500 error.
Status: 500 Internal Server Error
delete_all, accepted HTTP methods are delete, head, get, options, post, and put
Hello, I have tried everything and still get the 500 error. This is what I have:
in routes.rb I have tried various combinations:
map.connect 'work_schedules/:delete_al
map.connect 'work_schedules/delete_all
map.connect 'work_schedules/:delete_al
map.connect 'work_schedules/delete_all
map.connect 'work_schedules_controller
map.connect 'work_schedules_controller
In the work schedules controller:
def delete_all_scheds
my_count = WorkSchedule.count
if my_count >0
my_count.times do
@work_schedules = WorkSchedule.find(:first)
@work_schedule = WorkSchedule.find(@work_sc
end
end
respond_to do |format|
format.html { redirect_to(work_schedules
format.xml { head :ok }
end
end
In the work schedules view:
<td><%= link_to 'Delete Scheds', work_schedule, :confirm => 'Are you sure?', :method => :delete_all_scheds %></td>
Can it be that it is just not possible to have any action in the controller other than the default ones?
@witgrefe... Two things to try:
1. Have you looked at the development log to see what the last thing was that executed successfully? That will give you more information. You can find the logs under the log directory under your appliation: the file is development.log (assuming this is still in development).
2. Rather than looping through the items, just give the array of schedules to destroy, as in the code snippet. destroy and friends can all delete a group of elements, not just a single one, so you don't have to take a count and do them one-by-one... as long as you limit the find() to the specific set of records that you want. I am assuming that you have something like Employees have_many WorkSchedules.
Cheers...jon
@witgrefe: I tested the following code in my application and it definitely deletes all the associated records wihtout error. I have a list of assets associated with a user (user has_many assets).
I created a route to delete_all_assets and then added the code below... Note that I save the user id in the session -- you probably have the employee name stored somewhere else as well.
You'll have to change this to match your Classes and attributes... I've given you a sample below.
Make sure you use the redirect_to, since you probably want to send them back to a generic listing after you've deleted the work schedules...
Business Accounts
Answer for Membership
by: GertonePosted on 2008-03-21 at 08:54:07ID: 21180779
do you mean as a controller action, works?
so that root/controller/delete_all
If you add the method definition in the controller, you should be able to do so
make sure that the method definition does not come after a PRIVATE