Hi all,
I''m learning Rails by Example (chapter 11), by Michael Hartl (
http://ruby.railstutorial.org/chapters/user-microposts#top) but I got no
route matches when I try to delete one micropost.
the _micropost html is...
<tr>
  <td class="micropost">
    <span class="content"><%= micropost.content
%></span>
    <span class="timestamp">
      Posted <%= time_ago_in_words(micropost.created_at) %> ago.
    </span>
  </td>
  <% if current_user?(micropost.user) %>
    <td>
    <%= link_to "delete", micropost, :method  => :delete,
                    :confirm => "You sure?",
                       :title   => micropost.content %>
    </td>
  <% end %>
</tr>
the controller is...
class MicropostsController < ApplicationController
before_filter :authenticate, :only => [:create, :destroy]
before_filter :authorized_user, :only => :destroy
def create
@micropost = current_user.microposts.build(params[:micropost])
if @micropost.save
flash[:success] = "Micropost created!"
redirect_to root_path
else
@feed_items = []
render ''pages/home''
end
end
def destroy
@micropost.destroy
redirect_back_or root_path
end
private
def authorized_user
@micropost = current_user.microposts.find(params[:id])
rescue
redirect_to root_path
end
end
and finally, the route is..
SampleApp::Application.routes.draw do
  resources :users
  resources :sessions,   :only => [:new, :create, :destroy]
  resources :microposts, :only => [:create, :destroy]
  match ''/signup'',  :to => ''users#new''
  match ''/signin'',  :to => ''sessions#new''
  match ''/signout'', :to =>
''sessions#destroy''
  match ''/contact'', :to =>
''pages#contact''
  match ''/about'',   :to => ''pages#about''
  match ''/help'',    :to => ''pages#help''
    root :to => ''pages#home''
end
Please, let me know if you can help me.
-- 
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 Nov 12, 11:06 am, joao souza <joa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > I''m learning Rails by Example (chapter 11), by Michael Hartl (http://ruby.railstutorial.org/chapters/user-microposts#top) but I got no > route matches when I try to delete one micropost. >Your browser is doing a get request, which implies that> <%= link_to "delete", micropost, :method => :delete, > :confirm => "You sure?", > :title => micropost.content %>the :method => :delete option isn''t having the desired effect. This usually means that something is wrong with your javascript setup (e.g. you aren''t loading the javascript that makes :method => :delete work) 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.
Hi Frederick, Please, help me to solve it. I did "bundle update" to update javascript plugin (jquery-rails (1.0.17)) but it don''t solve the issue. On Sat, Nov 12, 2011 at 12:30 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Nov 12, 11:06 am, joao souza <joa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi all, > > > > I''m learning Rails by Example (chapter 11), by Michael Hartl ( > http://ruby.railstutorial.org/chapters/user-microposts#top) but I got no > > route matches when I try to delete one micropost. > > > > Your browser is doing a get request, which implies that > > > <%= link_to "delete", micropost, :method => :delete, > > :confirm => "You sure?", > > :title => micropost.content %> > > the :method => :delete option isn''t having the desired effect. This > usually means that something is wrong with your javascript setup (e.g. > you aren''t loading the javascript that makes :method => :delete work) > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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 Nov 12, 5:52 pm, joao souza <joa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Frederick, > > Please, help me to solve it. I did "bundle update" to update javascript > plugin (jquery-rails (1.0.17)) but it don''t solve the issue.Did you follow the instructions at https://github.com/indirect/jquery-rails ? 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.
On 13 November 2011 13:03, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Nov 12, 5:52 pm, joao souza <joa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Hi Frederick, >> >> Please, help me to solve it. I did "bundle update" to update javascript >> plugin (jquery-rails (1.0.17)) but it don''t solve the issue. > > Did you follow the instructions at https://github.com/indirect/jquery-rails > ?In addition to Fred''s suggestions you could try pasting the complete page html (View > Page Source or similar in browser) into the w3c html validator to check for valid html, and also run Firefox with Firebug enabled and see if it throws any errors when you click the link. 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.