I'm trying to use an AJAX call in my code, but I doesn't seem to be able
to find the method I'm trying to call, am I missing something really
obvious here??
I have a method dynamic_form in the TasksController class.
Something is wrong since the shouldnt be a passing :page=>nil, :ascending=>nil,:per_page=>nil in the params , view the html code and check what action is been called in the html form tag, it should be calling your_controller_name/dynamic_form (the path i gave you was for a restful action like create and update not for a custom action like the one you have, sorry), what you have here is a custom action, but you can make it restful like this
resources :your_controller do
member do
get :dynamic_form <===== get since i assume this is a search method
end
end
then you will have a new restful action and you can refer to it like this
form_for dynamic_form_your_controller_path, :remote=> true do |f|
it will work, just remember to change your_controller with the actual name of your controller, to make sure you can check it by typing rake routes.
Something is wrong since the shouldnt be a passing :page=>nil,
:ascending=>nil,:per_page=>nil in the params , view the html code and
check
what action is been called in the html form tag, it should be calling
your_controller_name/dynamic_form (the path i gave you was for a restful
action like create and update not for a custom action like the one you
have,
sorry), what you have here is a custom action, but you can make it
restful
like this
Hi Radhames,
Its actually being called by the :onchange part of the form, using a
remote function call like this:
I'm trying to use an AJAX call in my code, but I doesn't seem to be able
to find the method I'm trying to call, am I missing something really
obvious here??
What's in your routes file? You may need to add the dynamic_form
action to the mapping defined there (see
If you need to now how to do this step by step, just have to post a bit
more
of your view code.
and the actions you want to call is can be access by
task_dynamic_form_path
Apologies Radhames, I did include it in my first post, but I guess i
could have been more clear!
Here is my view code. What it basically is supposed to do is run a
little bit of js that replaces some of html when the first drop down box
is changed.
This here is the problem this is calling url => tasks_path because is working the same as the submit button and that is your index action
dynamic_form in never called your logic is not rigth, but am going out to lunch now all help you in
I managed to resolve this one. It turns out the line i had inserted in
routes.rb was being affected by a 'members' statement before it, causing
it to generate the wrong route. I simply moved the line ahead of this to
resolve the issue, the AJAX call seems to work fine now.