Following Ruby-on-Rails tutorial and getting 'destroy users' doesn't work -


i've installed ruby on rails 3.2 , have been trying learn it. i've been following along ror 3.0 tutorial (http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-users#top) , far going (yes know there's 3.2 version).

currently stuck on section 10.4.2 teaches how add link destroy users. says add code

<%= link_to "delete", user, :method => :delete, :confirm => "you sure?",                             :title => "delete #{user.name}" %> 

as adding in apps/view/layout/application/html/erb

<%= javascript_include_tag :defaults %> 

it seems should take right destroy method in user controller, tutorial says not working me , cannot figure out why. link creates /user/:id. looked @ same section in 3.2 tutorial , same directions (but not have javascript include tag code). can't work following tutorial. not sure why not working or how work.

so clear, rather going destroy method in user controller, goes /user/:id show method.

deleting resource (a user in case) requires jquery_ujs javascript file included on page. quite common see 'show' action being called, because without jquery_ujs not sending hidden data indicates http delete verb.

try explicitly insert jquery_ujs follows:

<%= javascript_include_tag 'jquery_ujs' %> 

and see happens.

jquery_ujs designed '... unobtrusive scripting support file ruby on rails framework, not strictly tied specific backend.'. in other words, scans document, sees special data-* attributes , performs various actions depending on these attributes, example, appending hidden html elements, performing ajax requests, etc.

also note, in order use jquery_ujs, jquery should referenced (before).

hope helps.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -