Hello, all,
I observed that resource deletion fails in rails 3 without
javascript turned on.

Why? I have created a simple rails 3 application and tried deleting a
resource entry with javascript turned off.

Absolutely no custom code/changes.

I have put an example on github: git@github.com:anexiole/rails-
delete-fails-without-js.git

The only things I did were:
1) create the project
2) rails generate scaffold Guitar name:string
3) rake db:migrate
4) script/rails server
5) Go to localhost:3000/guitars and create a new entry
6) Disable javascript on your browser
7) click on "Destroy" . The "show" action gets called instead

Is any body noticing this with rails 3.0.9 too?

thanks

--
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.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • K.M. at Sep 28, 2011 at 11:19 pm
    for some reason, the link for the github code did not come up properly
    before.
    Here's another try. git@github.com:anexiole/rails-delete-fails-without-
    js.git

    --
    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.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • comopasta Gr at Sep 29, 2011 at 8:09 am

    K.M. wrote in post #1024158:
    for some reason, the link for the github code did not come up properly
    before.
    Here's another try. git@github.com:anexiole/rails-delete-fails-without-
    js.git
    If you take a look at the code that your app generates for the index it
    looks something like this:

    <head>
    <title>Guitar</title>
    <link href="/stylesheets/scaffold.css?1317282309" media="screen"
    rel="stylesheet" type="text/css" />
    <script src="/javascripts/prototype.js?1317282218"
    type="text/javascript"></script>
    <script src="/javascripts/effects.js?1317282218"
    type="text/javascript"></script>
    <script src="/javascripts/dragdrop.js?1317282218"
    type="text/javascript"></script>
    <script src="/javascripts/controls.js?1317282218"
    type="text/javascript"></script>
    <script src="/javascripts/rails.js?1317282218"
    type="text/javascript"></script>
    <script src="/javascripts/application.js?1317282218"
    type="text/javascript"></script>
    <meta name="csrf-param" content="authenticity_token"/>
    <meta name="csrf-token"
    content="WF9XbwuCjb8sI6ZkZSI/9Wx/I3X5LswsFjeN5Qd4gIs="/>
    </head>
    <body>

    <h1>Listing guitars</h1>

    <table>
    <tr>
    <th>Name</th>
    <th></th>
    <th></th>
    <th></th>
    </tr>

    <tr>
    <td>Ibanez</td>
    <td><a href="/guitars/1">Show</a></td>
    <td><a href="/guitars/1/edit">Edit</a></td>
    <td><a href="/guitars/1" data-confirm="Are you sure?"
    data-method="delete" rel="nofollow">Destroy</a></td>
    </tr>
    </table>

    <br />

    <a href="/guitars/new">New Guitar</a>


    </body>
    </html>

    As you can see javascript is needed. In the part you see for the delete
    link using data-method, data-confirm, etc. All that relies on
    javascript. It goes to show method because it sends a GET request
    instead of a DELETE request. So it doesn't work because YOU have
    disabled javascript.

    You can use pure HTML to do the same thing by creating your own form
    anyway and don't rely on what Rails provides you. But I don't know what
    are you trying to build. I can think of very few web apps that wouldn't
    use javascript nowadays.

    Why are you disabling the javascript to start with?

    --
    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@googlegroups.com.
    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.
  • K.M. at Sep 29, 2011 at 12:36 pm
    hello there,


    Thank you comopasta Gr:)


    When I build web apps, accessibility is a factor I consider.

    One of the points with accessibility is to have the website still
    function when a user accesses it from a browser that does not have
    javascript.

    For example:
    1) users who do have very old computers and browsers without
    javascript (hey, they still provide revenue to your site anyway)
    2) users who are using screen readers (especially blind users)


    This is why I turned javascript off to simulate that environment.

    I'm quite dissappointed in the sense that rails 3 is now having such
    reliance on javascript and there's no proper fallback for cases when
    browsers/devices do not have javascript.



    Ok, if I were to do it without javascript, I would have to set up a
    form with method="DELETE" and a button for deletion.
    Would there be a better way?




    --
    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.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • 0v3rr!d3 at Oct 1, 2011 at 2:38 pm
    Thats the way it is.
    Javascript should be turned on for delete to work.

    Regards;
    0v3rr!d3

    --
    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.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Vinod Kurup at Oct 1, 2011 at 2:38 pm

    On Wed, Sep 28, 2011 at 8:26 AM, K.M. wrote:

    Hello, all,
    I observed that resource deletion fails in rails 3 without
    javascript turned on.

    The 'destroy' links use javascript, which is required for them to work. In
    order for your site to 'gracefully degrade' when javascript is turned off,
    you will have to make changes to the scaffolding.

    This link explains the situation (especially the last section):
    http://asciicasts.com/episodes/205-unobtrusive-javascript

    Vinod
    --
    Vinod Kurup, MD
    http://kurup.org

    --
    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.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedSep 28, '11 at 12:26p
activeOct 1, '11 at 2:38p
posts6
users4
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase