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.
Here is the error I get back in the browser.
-------------------------------------------
No route matches {:page=>nil, :escape=>false, :ascending=>nil,
:per_page=>nil, :group_filter=>"0",
:controller=>"tasks", :tab=>nil,
:search=>{}, :action=>"dynamic_form", :search_filter=>nil,
:column=>nil}
Extracted source (around line #18):
15: <%= f.text_field :title %>
16: <%= f.hidden_field :assigned_to_id, :value => current_user.id %>
17:
18: <label for="user_selected_app">Application:</label>
19: <%= select ''facet'',
''value'',Facets.application_list(["GBOSS",
"J_GMISEMEATC" ] ),{}, :onchange => remote_function(:url =>
{:action =>
''dynamic_form''}) %>
20:
21: <label for="user_selected_issuetype">Issue
Type:</label><strong id
= "user_selected_issuetype">
----------------------------------------
Thanks for looking guys,
I''m sure the answer is something really obvious!
--
Posted via http://www.ruby-forum.com/.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
what route you have in form_for? does this happen when you submit the form? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Radhames Brito wrote:> what route you have in form_for? does this happen when you submit the > form?<%= form_for(@task, :task) do |f| -%> Thanks -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Oct 8, 2010 at 12:05 PM, Paul Harte <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Radhames Brito wrote: > > what route you have in form_for? does this happen when you submit the > > form? > > <%= form_for(@task, :task) do |f| -%> >this wont build a route for the create action i think it should be <%= form_for(@task) do |f| -%> is either one or the other not both, you pass and instance or a symbol also if this is rails 3 this wont be submited with ajax since it lacks the :remote=> true option and in rails 2.3 it should be form_remote_for also your controller should respond to js. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Radhames,
Thanks for your tips.
I changed to the <%= form_for(@task, :remote=> true) do |f| -%>
format.
(I''m using rails3)
I also made sure my controller responds to js. I''m still getting the
same error:
"No route matches {:page=>nil, :ascending=>nil, :escape=>false,
:per_page=>nil, :group_filter=>"0", :tab=>nil,
:controller=>"tasks",
:search=>{}, :search_filter=>nil, :action=>"dynamic_form",
:column=>nil}"
Any other ideas?
Paul
Radhames Brito wrote:> On Fri, Oct 8, 2010 at 12:05 PM, Paul Harte
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
> wrote:
>
>> Radhames Brito wrote:
>> > what route you have in form_for? does this happen when you submit
the
>> > form?
>>
>> <%= form_for(@task, :task) do |f| -%>
>>
>
> this wont build a route for the create action i think it should be
>
> <%= form_for(@task) do |f| -%>
>
> is either one or the other not both, you pass and instance or a symbol
>
> also if this is rails 3 this wont be submited with ajax since it lacks
> the
> :remote=> true option
> and in rails 2.3 it should be form_remote_for
>
> also your controller should respond to js.
--
Posted via http://www.ruby-forum.com/.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
> > "No route matches {:page=>nil, :ascending=>nil, :escape=>false, > :per_page=>nil, :group_filter=>"0", :tab=>nil, :controller=>"tasks", > :search=>{}, :search_filter=>nil, :action=>"dynamic_form", > :column=>nil}" > >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. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>> > 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: :onchange => remote_function(:url => {:action => ''dynamic_form''} Could i just assign values to the :page, :asceding and :per_page within this call? Thanks for your help so far, I''m sure the solution will prove to be simple!! Paul -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Oct 8, 4:41 pm, Paul Harte <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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 http://guides.rubyonrails.org/routing.html#adding-more-restful-actions or http://guides.rubyonrails.org/v2.3.8/routing.html#adding-more-restful-actions) Fred> > I have a method dynamic_form in the TasksController class. > > Here is the error I get back in the browser. > ------------------------------------------- > > No route matches {:page=>nil, :escape=>false, :ascending=>nil, > :per_page=>nil, :group_filter=>"0", :controller=>"tasks", :tab=>nil, > :search=>{}, :action=>"dynamic_form", :search_filter=>nil, :column=>nil} > > Extracted source (around line #18): > > 15: <%= f.text_field :title %> > 16: <%= f.hidden_field :assigned_to_id, :value => current_user.id %> > 17: > 18: <label for="user_selected_app">Application:</label> > 19: <%= select ''facet'', ''value'',Facets.application_list(["GBOSS", > "J_GMISEMEATC" ] ),{}, :onchange => remote_function(:url => {:action => > ''dynamic_form''}) %> > 20: > 21: <label for="user_selected_issuetype">Issue Type:</label><strong id > = "user_selected_issuetype"> > > ---------------------------------------- > > Thanks for looking guys, > > I''m sure the answer is something really obvious! > -- > Posted viahttp://www.ruby-forum.com/.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > What''s in your routes file? You may need to add the dynamic_form > action to the mapping defined there (see > http://guides.rubyonrails.org/routing.html#adding-more-restful-actions > or > http://guides.rubyonrails.org/v2.3.8/routing.html#adding-more-restful-actions) > > FredHi Fred, I''ve tried various different things in my routes file. At the moment, this is what it contains: match ''dynamic_form'' => ''tasks#dynamic_form'' this is what rake routes gives back atm task_dynamic_form /tasks/:task_id/dynamic_form(.:format) {:controller=>"tasks", :action=>"dynamic_form"} Any help you might have is greatly appreciated! Thanks, Paul -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > :onchange => remote_function(:url => {:action => ''dynamic_form''} >you should have said this in the first place, use jquery, with its live function is the unobstrusive way, then sent a getscript, return js.erb action. 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 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Radhames Brito wrote:> 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_pathApologies 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. <%= form_for(@task, :remote=> true, :as=>:task, :url => tasks_path ) do |f| -%> <p> <%= f.label :title, ''New task:'' %> <%= f.text_field :title %> <%= f.hidden_field :assigned_to_id, :value => current_user.id %> <label for="user_selected_app">Application:</label> <%= select ''facet'', ''value'',Facets.application_list(["GBOSS", "J_GMISEMEATC" ] ),{}, :onchange => remote_function(:url => {:action => ''dynamic_form''} ) %> <label for="user_selected_issuetype">Issue Type:</label><strong id = "user_selected_issuetype"> <%= select ''task'', ''issue_type'', options_for_select(@task.sti_issue_type_list(User.current_user.group.id), :selected => session[:default_task_issue_type]), {}, :onchange => "$(''task_submit'').simulate(''click'')" %> </strong> <%= f.submit ''Create'' %> <% end -%> </p> -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Oct 11, 4:35 pm, Paul Harte <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > What''s in your routes file? You may need to add the dynamic_form > > action to the mapping defined there (see > >http://guides.rubyonrails.org/routing.html#adding-more-restful-actions > > or > >http://guides.rubyonrails.org/v2.3.8/routing.html#adding-more-restful...) > > > Fred > > Hi Fred, > > I''ve tried various different things in my routes file. > > At the moment, this is what it contains: > > match ''dynamic_form'' => ''tasks#dynamic_form'' >you''d want /tasks/dynamic form I think or the member {post ''dynamic_form''} stuff - check the url that is generated Fred -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> "$(''task_submit'').simulate(''click'')" %> >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 while -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hey guys, 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. Thanks for all your advice and tips, Paul -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.