ruby on rails 3 - No route matches [DELETE] "/models.id" Error -


i keep getting error , haven't found answer here addresses error.

i have book, user , model stated this:

class book < activerecord::base   attr_accessible :title    has_many :likes   has_many :users, through: :likes end  class user < activerecord::base   attr_accessible :name    has_many :likes   has_many :books, through: :likes end  class < activerecord::base   attr_accessible :book, :user    belongs_to :book   belongs_to :user end 

corresponding likes controllers:

# app/controllers/likes_controller.rb class likescontroller < applicationcontroller    def index     # assign logged in user @user     @user = current_user     # grab of books , put them array in @books     @books = book.all   end    def create      book = book.find(params[:book_id])     like.create(:book => book, :user => current_user)     redirect_to likes_path, :notice => "you liked book #{book.title}"    end    def destroy     = like.find(params[:id])     like.destroy     redirect_to likes_path, :notice => "you destroyed like"   end end 

in config/routers.rb:

myapp::application.routes.draw    resources :likes   end 

i have link supposed delete existing like:

<% = book.likes.where(:user_id => @user.id).first %>  <%= link_to "destroy like", likes_path(like.id), :method => :delete % 

but when click link, error:

no route matches [delete] "/likes.7"  

change likes_path(like.id) like_path(like) , enjoy :)


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -