ActionController::UnknownAction

Hi

I m new to RoR. I added a method to an already existing controller. i am calling that method from a view (roadmap). I also added following code in route.rb

project_actions.connect 'projects/draganddropsort', :action => 'draganddropsort'

**portionwhere i call my function** <%= sortable_element 'issue-list', :url => {:action => :draganddropsort, :issue_list => issues }, :complete => visual_effect(:highlight, 'issue-list'), :tag => 'tr' %>

Do you have that same method in yours projects controller ?

yes . i have same method in projects_controller.rb

def draganddropsort   .....   end

Kannav R. wrote in post #974224:

Do you have that same method in yours projects controller ?

<%= sortable_element 'issue-list', 2011-01-12 16:03:20) [POST] column_header, copy, current_language, current_menu_item, link_to_version, list_files, ll, logged_user=, menu_items, sort_header_tag, sort_init, sort_link, sort_name, sort_update, /usr/lib/ruby/1.8/action_controller/rescue.rb:160:in ....................... -- 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@googlegroups.com. To unsubscribe from this group, send email to

rubyonrails-talk+unsubscribe@googlegroups.com<rubyonrails-talk%2Bunsubscribe@googlegroups.com>

yes . i have same method in projects_controller.rb

And it's public?

Fred

Frederick Cheung wrote in post #974232:

The only suggestion I can think of is to check there’s no private or protected call on any of the lines above the method name or to check the routes file:

project_actions.connect ‘projects/draganddropsort’, :action => ‘draganddropsort’

Where is the project_actions coming from ? is it a block variable for map.resources :projects do |project_actions| ?

David

David White wrote in post #974243:

The only suggestion I can think of is to check there's no private or protected call on any of the lines above the method name or to check the routes file:

project_actions.connect 'projects/draganddropsort', :action => 'draganddropsort'

Where is the project_actions coming from ? is it a block variable for map.resources :projects do |project_actions| ?

David

projects.with_options :conditions => {:method => :post} do

project_actions|

Even i think some mistake in routing ..i did some workaround on it....but all in vain :(. I call draganddropsort method from roadmap view..and its route is been added like

map.with_options :controller => 'projects' do |projects| projects.with_options :conditions => {:method => :get} do

project_views|

..... project_views.connect 'projects/:id/:action', :action => 'roadmap' .... end Can anyone suggest possible routes that i can add.

Thanks anju

Maybe just keep it very simple with:

map.connect ‘projects/draganddropsort’, :controller => ‘projects’, :action => ‘draganddropsort’

And just see if you can access the draganddropsort method by navigating to it in your browser. Also might be worth running rake routes to see what routes are getting set.

David

when i tried 'http://127.0.0.1:3000/projects/1-strfronttech-011/draganddropsort’in browser, i got Unknown action

Anju

Whats 1-strfronttech-011 ?

If you’re passing parameters in the url then you’ll need to show that in the routes sometihng like.

map.connect 'projects/:your_parameter/draganddropsort, :controller => 'projects, :action => ‘draganddropsort’

You can access that parameter in your controller with params[:your_parameter]

David

David White wrote in post #974269:

Whats 1-strfronttech-011 ?

If you're passing parameters in the url then you'll need to show that in the routes sometihng like.

map.connect 'projects/:your_parameter/draganddropsort, :controller => 'projects, :action => 'draganddropsort'

You can access that parameter in your controller with params[:your_parameter]

David

yes i did map.connect 'projects/:id/draganddropsort', :controller => 'projects', :action => 'draganddropsort' in route.rb..

Could you post your projects controller? Might be able to see if there’s something wrong in there.

David

David White wrote in post #974274:

Could you post your projects controller? Might be able to see if there's something wrong in there.

David

Here is my projects_controller.rb.....

class ProjectsController < ApplicationController   menu_item :overview   menu_item :activity, :only => :activity   menu_item :roadmap, :only => [:roadmap]   menu_item :files, :only => [:list_files, :add_file]   menu_item :settings, :only => :settings

  before_filter :find_project, :except => [ :index, :list, :add, :copy, :activity,:draganddropsort ]   before_filter :find_optional_project, :only => :activity   before_filter :authorize, :except => [ :index, :list, :add, :copy, :archive, :unarchive, :destroy, :activity,:draganddropsort ]   before_filter :authorize_global, :only => :add   before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]   accept_key_auth :activity, :index

  after_filter :only => [:add, :edit, :archive, :unarchive, :destroy] do

controller>

    if controller.request.post?       controller.send :expire_action, :controller => 'welcome', :action => 'robots.txt'     end   end

  helper :sort   include SortHelper   helper :custom_fields   include CustomFieldsHelper   helper :issues   helper :queries   include QueriesHelper   helper :repositories   include RepositoriesHelper   include ProjectsHelper

  # Lists visible projects   def index     ....   end

  # Add a new project   def add    ....   end

............... ....................

  def draganddropsort   #@issue = Issue.find_by_id(params["1479"])   @issues = Issue.find(params[:issue_list])   @issues.each do |issue|           #issue.custom_field_values.value = params['issue-list' ].index(issue.id.to_s) + 1     issue.subject = "test"     issue.save   end   render :nothing => true   end

end

Thanks Anju

I resolved the issue It was a PEBKAC, accidentally I defined my method under a set of private methods :(.

Thanks David

David White wrote in post #974243: