Hi All, I''m very new to RoR development and am working through the developer.apple.com tutorials to try to get a good enough working knowledge to be able to start my own project. Unfortunately, i''m using Rails 3 and the tutorials are aimed at a Rails 2 environment. I''ve been able to get a fair way through the tutorials, working out some of the simpler changes myself (changes to the routing API were interesting), but i''ve hit a point where i''m stuck and google hasn''t been able to help me. I''m currently working through the "Spicing it up with Ajax" section of http://developer.apple.com/tools/customizeonrailsleopard.html but am unable to successfully convert the Rails 2 link_to_remote syntax into Rails 3. I understand that the method is depreciated and that i should use link_to with a :remote => true option specified, but the arguments that i''m supplying don''t seem to be being picked up as a Javascript link. Instead, when i click one of the links, the whole page is refreshed and the arguments appear in the address bar (instead of an Ajax call). E.g. http://localhost:3000/events/4?remote=true&method=delete&confirm=Are+you+sure%3F&url=http%3A%2F%2Flocalhost%3A3000%2Fevents%2F4%2Fexpenses%2F6 My _expenses.erb event looks like so: ...<% for expense in expenses -%> <tr id="<%= dom_id(expense) %>"> <td> <%= link_to expense.vendor.name, expense.vendor %> </td> <td align="right"> <%= number_to_currency(expense.amount, :unit => "£") %> </td> <td> <%= link_to ''delete'', :url => event_expense_url(event, expense), :confirm => ''Are you sure?'', :method => :delete, :remote => true %> </td> </tr> <% end -%>... and my application.html.erb file: <!DOCTYPE html> <html> <head> <title>Expenses</title> <%= stylesheet_link_tag :all %> <%= javascript_include_tag :defaults %> <%= csrf_meta_tag %> </head> <body> <%= yield %> </body> </html> I''d be very grateful if anyone could offer some advice. Apologies if the source code is too long for the forum. Thanks, Dave. -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Oct 15, 6:12 am, David Weldon <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > I''d be very grateful if anyone could offer some advice. Apologies if the > source code is too long for the forum. >if the rails.js file in public/javascripts? Is it being loaded? That is the file that :remote => true is going to try to call. I seem to remember that this is one of the major gotchas on a 2 to 3 conversion. Steve -- 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.
Thanks for the quick response, Steve. The rails.js file is in the public/javascripts and it can be seen in the source of my page: <script src="/javascripts/rails.js?1285525822" type="text/javascript"></script> The link that is generated by the call to link_to is: <a href="/events/4?remote=true&method=delete&confirm=Are+you+sure%3F&url=http%3A%2F%2Flocalhost%3A3000%2Fevents%2F4%2Fexpenses%2F6">delete</a> Which mentions remote=true, but doesn''t appear to make any reference to javascript. I made a successful Ajax call in the prior part of the tutorial, only this time with the following syntax: <%= form_for [@event, @expense], :remote => true do |f| -%> -- 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.
The standard delete link created by scaffold is <%= link_to ''Destroy'', question, :confirm => ''Are you sure?'', :method => :delete %> There is no reference to remote. Delete is not an ajax call, it is just a javascript call that hides all the build a delete form stuff that happened in Rails 2.x. By putting in :remote, it was probably trying to do an Unobtrusive Javascript call to an unknown method. I think!!! If you are just trying to replace the delete link on the Apple demo, try the above line. Steve On Oct 15, 8:40 am, David Weldon <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Thanks for the quick response, Steve. The rails.js file is in the > public/javascripts and it can be seen in the source of my page: > > <script src="/javascripts/rails.js?1285525822" > type="text/javascript"></script> > > The link that is generated by the call to link_to is: > > <a > href="/events/4?remote=true&method=delete&confirm=Are+you+sure%3F&a mp;url=http%3A%2F%2Flocalhost%3A3000%2Fevents%2F4%2Fexpenses%2F6">delete</a > > > Which mentions remote=true, but doesn''t appear to make any reference to > javascript. > > I made a successful Ajax call in the prior part of the tutorial, only > this time with the following syntax: > > <%= form_for [@event, @expense], :remote => true do |f| -%> > > -- > 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.
On 15 October 2010 12:12, David Weldon <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi All, > > I''m very new to RoR development and am working through the > developer.apple.com tutorials to try to get a good enough working > knowledge to be able to start my own project. Unfortunately, i''m using > Rails 3 and the tutorials are aimed at a Rails 2 environment.Rather than trying to learn rails 2 and 3 at once you might be better to use a Rails 3 tutorial such as railstutorial.org. This is available online free though initially it looks as if you have to pay. Colin -- 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.