Note that there are some explanatory texts on larger screens.

plurals
  1. PORouting Error No route matches [GET] "/microposts/304 - Deleting a Micropost - Michael Hartl's railstutorial.org Chapter 11
    primarykey
    data
    text
    <p>I'm working through Michael Hartl's Ruby on Rails tutorial on <a href="http://ruby.railstutorial.org" rel="nofollow noreferrer">http://ruby.railstutorial.org</a>. I'm having trouble with Chapter 11, specifically when attempting to delete a micropost. </p> <p>I'm having the same problem as this user <a href="https://stackoverflow.com/questions/5871875/no-route-matches-error-on-delete-of-micropost-in-chapter-11-of-hartls-ruby-on">Routing Error No route matches [GET] "/microposts/304"</a>. He was able to solve the problem by commenting out the jQuery gem and it worked. I, however, wasn't as lucky. </p> <p>Here is my current Gemfile:</p> <pre><code>source 'http://rubygems.org' gem 'rails', '3.1.1' # Bundle edge Rails instead: # gem 'rails', :git =&gt; 'git://github.com/rails/rails.git' gem 'sqlite3' gem 'gravatar_image_tag', '1.0.0.pre2' gem 'will_paginate', '3.0.pre2' gem 'jquery-rails' gem 'pg' group :development do gem 'faker', '0.3.1' end # Gems used only for assets and not required # in production environments by default. #group :assets do # gem 'sass-rails', '~&gt; 3.1.4' # gem 'coffee-rails', '~&gt; 3.1.1' # gem 'uglifier', '&gt;= 1.0.3' #end # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~&gt; 3.0.0' # Use unicorn as the web server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger # gem 'ruby-debug19', :require =&gt; 'ruby-debug' group :test do # Pretty printed test output gem 'turn', :require =&gt; false end </code></pre> <p>=> A quick side-note: An error <a href="https://stackoverflow.com/questions/8047651/no-javascript-runtime-on-windows-when-running-rails-server">No Javascript runtime on windows when running rails server</a> kept arising when I ran the <code>rails server</code> command but once I commented out the <code>'sass-rails'</code>, <code>'coffee-rails'</code>, and <code>'uglifier'</code> gems it would run successfully. I'm using a Windows PC and was told that this might be a specific problem to Windows machines.</p> <p>Also, here is the current outcome of my <code>bundle install</code> command:</p> <pre><code>Using rake (0.9.2.2) Using multi_json (1.0.3) Using activesupport (3.1.1) Using builder (3.0.0) Using i18n (0.6.0) Using activemodel (3.1.1) Using erubis (2.7.0) Using rack (1.3.5) Using rack-cache (1.1) Using rack-mount (0.8.3) Using rack-test (0.6.1) Using hike (1.2.1) Using tilt (1.3.3) Using sprockets (2.0.3) Using actionpack (3.1.1) Using mime-types (1.17.2) Using polyglot (0.3.3) Using treetop (1.4.10) Using mail (2.3.0) Using actionmailer (3.1.1) Using arel (2.2.1) Using tzinfo (0.3.31) Using activerecord (3.1.1) Using activeresource (3.1.1) Using ansi (1.4.1) Using bundler (1.0.21) Using faker (0.3.1) Using gravatar_image_tag (1.0.0.pre2) Using rack-ssl (1.3.2) Using json (1.6.1) Using rdoc (3.11) Using thor (0.14.6) Using railties (3.1.1) Using jquery-rails (1.0.17) Using pg (0.11.0) Using rails (3.1.1) Using sqlite3 (1.3.4) Using turn (0.8.3) Using will_paginate (3.0.pre2) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. </code></pre> <p>I'm not sure how to solve this problem. <strong>Is there a specific gem that I need to install in order for the delete method to work?</strong> I appreciate your help!</p> <p>Here is the <code>rake routes</code> output:</p> <pre><code>(in C:/rails_projects/sample_app) users GET /users(.:format) {:action=&gt;"index", :controller=&gt;"us ers"} POST /users(.:format) {:action=&gt;"create", :controller=&gt;"u sers"} new_user GET /users/new(.:format) {:action=&gt;"new", :controller=&gt;"user s"} edit_user GET /users/:id/edit(.:format) {:action=&gt;"edit", :controller=&gt;"use rs"} user GET /users/:id(.:format) {:action=&gt;"show", :controller=&gt;"use rs"} PUT /users/:id(.:format) {:action=&gt;"update", :controller=&gt;"u sers"} DELETE /users/:id(.:format) {:action=&gt;"destroy", :controller=&gt;" users"} sessions POST /sessions(.:format) {:action=&gt;"create", :controller=&gt;"s essions"} new_session GET /sessions/new(.:format) {:action=&gt;"new", :controller=&gt;"sess ions"} session DELETE /sessions/:id(.:format) {:action=&gt;"destroy", :controller=&gt;" sessions"} microposts POST /microposts(.:format) {:action=&gt;"create", :controller=&gt;"m icroposts"} micropost DELETE /microposts/:id(.:format) {:action=&gt;"destroy", :controller=&gt;" microposts"} signup /signup(.:format) {:controller=&gt;"users", :action=&gt;"ne w"} signin /signin(.:format) {:controller=&gt;"sessions", :action=&gt; "new"} signout /signout(.:format) {:controller=&gt;"sessions", :action=&gt; "destroy"} contact /contact(.:format) {:controller=&gt;"pages", :action=&gt;"co ntact"} about /about(.:format) {:controller=&gt;"pages", :action=&gt;"ab out"} help /help(.:format) {:controller=&gt;"pages", :action=&gt;"he lp"} root / {:controller=&gt;"pages", :action=&gt;"ho me"} </code></pre> <p>Here is a partial view file using the delete method:</p> <pre><code>&lt;tr&gt; &lt;td class="micropost"&gt; &lt;span class="content"&gt;&lt;%= micropost.content %&gt;&lt;/span&gt; &lt;span class="timestamp"&gt; Posted &lt;%= time_ago_in_words(micropost.created_at) %&gt; ago. &lt;/span&gt; &lt;/td&gt; &lt;% user = micropost.user rescue User.find(micropost.user_id) %&gt; &lt;% if current_user?(user) %&gt; &lt;td&gt; &lt;%= link_to "delete", micropost, :method =&gt; :delete, :confirm =&gt; "You sure?", :title =&gt; micropost.content %&gt; &lt;/td&gt; &lt;% end %&gt; &lt;/tr&gt; </code></pre> <p>Again, the source code can be viewed on Github <a href="https://github.com/railstutorial/sample_app" rel="nofollow noreferrer">https://github.com/railstutorial/sample_app</a>, it just seems to not be running properly on my machine which leads me to believe it is something along the lines as this <a href="https://stackoverflow.com/questions/5871875/no-route-matches-error-on-delete-of-micropost-in-chapter-11-of-hartls-ruby-on">user's</a> problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload