Using http://guides.rubyonrails.org/getting_started.html as a guide.
  Create, Read, Delete all work. Update fails:

NoMethodError in WordsController#update

private method `update' called for #<Word:0xae98360>

(I chose to make a list of words rather than of posts.)


The Request parameters:

{"utf8"=>"✓",
  "_method"=>"put",
  "authenticity_token"=>"HizJaASbs53QXfgRZk8SbZ+6OcDigR7LtDtpEGHXwMY=",
  "word"=>{"word"=>"feline",
  "definition"=>"Like a cat; stealthy"},
  "commit"=>"Update Word",
  "id"=>"3"}

The "update" method from the controller:

class WordsController < ApplicationController
...
   def update
     @word = Word.find(params[:id])

     if @word.update(params[:definition])
       redirect_to @word
     else
       render 'edit'
     end
   end


rake routes:
...
       PUT /words/:id(.:format) words#update
...

Context information:
rails -v
Rails 3.2.2

ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [i686-linux]

In case relevant: CentOS release 5.5 (Final)


I'm sure this is a simple thing and may have to do with a different version
of Rails. However, I've not had success pursuing that line.

Does anyone have a good idea why I'd be getting the error on the update
method?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/95377e22-3471-4e3a-9d19-a331eb4dd3df%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Colin Law at Aug 22, 2013 at 9:36 am

    On 21 August 2013 19:01, wrote:
    Using http://guides.rubyonrails.org/getting_started.html as a guide.
    Create, Read, Delete all work. Update fails:

    NoMethodError in WordsController#update
    ...
    class WordsController < ApplicationController
    ...
    def update
    @word = Word.find(params[:id])

    if @word.update(params[:definition])
    That should be @word.update_attributes( ..)

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtMCK1Wuyc7iRZbX5MGBe5_%3DN%2BGJKWU4hszpXyubo__9A%40mail.gmail.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedAug 22, '13 at 8:57a
activeAug 22, '13 at 9:36a
posts2
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Colin Law: 1 post Rick Toews: 1 post

People

Translate

site design / logo © 2022 Grokbase