[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

N00b request help with scaffold- undefined method 'body=' error

NOCTURE

2/26/2006 2:31:00 AM

Hey guys,

I'm trying to work my way through the Ruby on Rails tutorial building
CRUD actions using scaffold based on a single database table.

the "list" action seems to work well, but all other actions result in
errors.

See trace below ..

I am only 2 hours into my Ruby (rails) experience and I have no idea how
to track down this bug.

Here's the top part of my ResponseController code:

class ResponsesController < ApplicationController
def index
list
render :action => 'list'
end

def list
@response_pages, @responses = paginate :responses, :per_page => 10
end

def show
@response = Response.find(params[:id])
end

def new
@response = Response.new
end


Any help appreciated!

Thanks!




undefined method `body=' for #<Response:0xb756fed8>

RAILS_ROOT: script/../config/..
Application Trace | Framework Trace | Full Trace

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1498:in
`method_missing'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:694:in
`erase_render_results'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:712:in
`erase_results'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:28:in
`rescue_action'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:108:in
`perform_action'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in
`process_without_session_management_support'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in
`process'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in
`dispatch'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in
`handle_dispatch'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in
`service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in
`dispatch'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require'
9 Answers

hampton c

2/26/2006 3:54:00 PM

0

If I had this error, I'd guess that I don't have the attribute "body"
in my "responses" table. Though, I don't know the particulars of your
setup, so it could be many things.

However, please note that scaffolding is not the preferred way to learn
Rails. And, secondly, there is a rails dedicated group that is probably
a better place for rails questions.

But, anyhow, goodluck with it!

-hampton.

Guillaume Benny

2/26/2006 4:21:00 PM

0

>
> the "list" action seems to work well, but all other actions result in
> errors.
>
>
> class ResponsesController < ApplicationController
> def index
> list
> render :action => 'list'
> end
>
> def list
> @response_pages, @responses = paginate :responses, :per_page => 10
> end
>
> def show
> @response = Response.find(params[:id])
> end
>
> def new
> @response = Response.new
> end
>
>

Hi,

My guess is that "response" is something special in Rails (so is "request"
if I remember correctly). You are probably overwriting a Rails instance
variable... Try renaming @response to something else. It might even be your
"Response" model that's confusing Rails: maybe there is a Response class in
Rails. Try renaming it to something else...

I hope this will help...

Guillaume




Jeff McNeil

2/26/2006 4:42:00 PM

0

Shouldn't you also be inheriting from ActionController and not
ApplicationController? Have a look at the ActionController class
(http://rubyonrails.org/api/classes/ActionController...).
I've always thought that ApplicationController was a top-level abstract?

Thanks,

Jeff
(Oh, hi! I don't post much, but I enjoy reading what everyone else
does =)

On Feb 26, 2006, at 11:21 AM, Guillaume Benny wrote:

>>
>> the "list" action seems to work well, but all other actions result in
>> errors.
>>
>>
>> class ResponsesController < ApplicationController
>> def index
>> list
>> render :action => 'list'
>> end
>>
>> def list
>> @response_pages, @responses = paginate :responses, :per_page
>> => 10
>> end
>>
>> def show
>> @response = Response.find(params[:id])
>> end
>>
>> def new
>> @response = Response.new
>> end
>>
>>
>
> Hi,
>
> My guess is that "response" is something special in Rails (so is
> "request"
> if I remember correctly). You are probably overwriting a Rails
> instance
> variable... Try renaming @response to something else. It might even
> be your
> "Response" model that's confusing Rails: maybe there is a Response
> class in
> Rails. Try renaming it to something else...
>
> I hope this will help...
>
> Guillaume
>
>
>



NOCTURE

2/26/2006 5:42:00 PM

0

Thanks, Guillaume.

This was the problem. I renamed my controller and things started
working as they were designed.

Thankyou,
na


Guillaume Benny wrote:
>>the "list" action seems to work well, but all other actions result in
>>errors.
>>
>>
>>class ResponsesController < ApplicationController
>> def index
>> list
>> render :action => 'list'
>> end
>>
>> def list
>> @response_pages, @responses = paginate :responses, :per_page => 10
>> end
>>
>> def show
>> @response = Response.find(params[:id])
>> end
>>
>> def new
>> @response = Response.new
>> end
>>
>>
>
>
> Hi,
>
> My guess is that "response" is something special in Rails (so is "request"
> if I remember correctly). You are probably overwriting a Rails instance
> variable... Try renaming @response to something else. It might even be your
> "Response" model that's confusing Rails: maybe there is a Response class in
> Rails. Try renaming it to something else...
>
> I hope this will help...
>
> Guillaume
>
>
>
>

Harry Merrick

5/13/2010 3:32:00 PM

0

don diddi wrote:
> "Harry Merrick" <homestud@hotmail.com> wrote in message
> news:84v95eFjlU1@mid.individual.net...
>> don diddi wrote:
>>> On Sky News
>>>
>>> Liam Fox was expected to be Secretary of defence but it is reported
>>> that Paddy Ashdown has that position.
>>> Liam Fox is reported to be furious.
>>>
>>> Cameron already upsetting the backbenchers.
>>>
>>> lol
>>
>> You can rest assured that all these places have already been agreed
>> and accepted within the negotiations.
>
> You mean stitched up behind the electorates back

I don't think so. It was perfectly transparent.

>
>> So, your cozy conversations
>
> You sound jealous

Not of you. I don't like sour grapes.

>
>> trying to
>> sneer and smear the Coalition are as of nought! New Labour lost. The
>> Pendulum has swung! Get used to it!
>
> Er, got some news for you, you may have missed it but the Tories
> didn't win, hence the need for the socialist fake lib dems.

The Tories had over 2 million votes MORE than New Labour!, So, whilst nobody
actually won, New Labour was the worst loser! It is interesting to see that
New Labour was not good enough for the LibDems don't you think?

Apart from a full blown PR system, which would let in small parties such as
the BNP and UKip, this is a very good alternative.

Far be it for me to crow, but New Labour lost!! - As did *YOU* don diddi!!!
ROTFLMAO!

We have gone away from the shallow, deceitfull, sneeringly Unionised,
non-government displayed for the last thirteen years.

--
Harry Merrick.

don diddi

5/13/2010 9:52:00 PM

0



"Harry Merrick" <homestud@hotmail.com> wrote in message
news:852kc7Fur2U1@mid.individual.net...
> don diddi wrote:
>> "Harry Merrick" <homestud@hotmail.com> wrote in message
>> news:84v95eFjlU1@mid.individual.net...
>>> don diddi wrote:
>>>> On Sky News
>>>>
>>>> Liam Fox was expected to be Secretary of defence but it is reported
>>>> that Paddy Ashdown has that position.
>>>> Liam Fox is reported to be furious.
>>>>
>>>> Cameron already upsetting the backbenchers.
>>>>
>>>> lol
>>>
>>> You can rest assured that all these places have already been agreed
>>> and accepted within the negotiations.
>>
>> You mean stitched up behind the electorates back
>
> I don't think so. It was perfectly transparent.

Funny, didn't see that on my ballot paper

>>
>>> So, your cozy conversations
>>
>> You sound jealous
>
> Not of you. I don't like sour grapes.

Stating the facts isn't sour grapes

>>> trying to
>>> sneer and smear the Coalition are as of nought! New Labour lost. The
>>> Pendulum has swung! Get used to it!
>>
>> Er, got some news for you, you may have missed it but the Tories
>> didn't win, hence the need for the socialist fake lib dems.
>
> The Tories had over 2 million votes MORE than New Labour!
>, So, whilst nobody actually won, New Labour was the worst loser!

You missed your maths class I see

>It is interesting to see that
> New Labour was not good enough for the LibDems don't you think?

It wasn't the answer, it wouldn't have produced a majority gov't, it was
messy.
Best let them the socialist fake lib dems and Tories sell themselves out in
a coalition.
After they have finished with their cuts no one will vote for them, then
Labour will be back in.

> Apart from a full blown PR system, which would let in small parties such
> as the BNP and UKip, this is a very good alternative.

The BNP vote went down

> Far be it for me to crow, but New Labour lost!! - As did *YOU* don
> diddi!!! ROTFLMAO!
>
> We have gone away from the shallow, deceitfull, sneeringly Unionised,
> non-government displayed for the last thirteen years.

Enjoy it while you can ;-)

Harry Merrick

5/17/2010 10:20:00 AM

0

don diddi wrote:
> "Harry Merrick" <homestud@hotmail.com> wrote in message
> news:852kc7Fur2U1@mid.individual.net...
>> don diddi wrote:
>>> "Harry Merrick" <homestud@hotmail.com> wrote in message
>>> news:84v95eFjlU1@mid.individual.net...
>>>> don diddi wrote:
>>>>> On Sky News
>>>>>
>>>>> Liam Fox was expected to be Secretary of defence but it is
>>>>> reported that Paddy Ashdown has that position.
>>>>> Liam Fox is reported to be furious.
>>>>>
>>>>> Cameron already upsetting the backbenchers.
>>>>>
>>>>> lol
>>>>
>>>> You can rest assured that all these places have already been agreed
>>>> and accepted within the negotiations.
>>>
>>> You mean stitched up behind the electorates back
>>
>> I don't think so. It was perfectly transparent.
>
> Funny, didn't see that on my ballot paper

I presume you ballot paper is different to everyone elses then. It is
perfectly normal practice to negotiate for a coalition with another party if
there is a hung parliament. Why would we, the hoi polloi, be involved in
discussions such as those, which we do not understand or have the correct
info for.

>
>>>
>>>> So, your cozy conversations
>>>
>>> You sound jealous
>>
>> Not of you. I don't like sour grapes.
>
> Stating the facts isn't sour grapes

It depends upon the nuances involved. Your's came through as sour grapes.

>
>>>> trying to
>>>> sneer and smear the Coalition are as of nought! New Labour lost.
>>>> The Pendulum has swung! Get used to it!
>>>
>>> Er, got some news for you, you may have missed it but the Tories
>>> didn't win, hence the need for the socialist fake lib dems.
>>
>> The Tories had over 2 million votes MORE than New Labour!
>> , So, whilst nobody actually won, New Labour was the worst loser!
>
> You missed your maths class I see

Really? See this:

Your guide to the poll results that matter
Conservative: 307 seats (2005: 198) Votes:10,706,647 36% (+3.8%)
Labour: 258 seats (2005: 356) Votes:8,604,358 29% (-6.2%)
Lib Dem:57 seats (2005: 62) Votes:6,827,938 23%(+1.0%)
DUP: 8 seats (2005: 9) Votes:168,216 0.6% (-0.3%)
SNP: 6 seats (2005: 6) Votes:491,386 1.7% (+0.1%)
Sinn Fein: 4 seats (2005: 5) Votes:171,942 0.6% (-0.1%)
Plaid Cymru: 3 seats (2005: 2) Votes:165,394 0.6% (-0.1%)
SDLP: 3 seats (2005: 3) Votes:110,970 0.4% (-0.1%)
Green: 1 seats (2005: 0) Votes:285,616 1% (-0.1%)
Alliance Party: 1 seats (2005: 0) Votes:42,762 (n/a)
Ukip: 0 seats (2005: 0) Votes:917,832 3.1% (+0.9%)
BNP: 0 seats (2005: 0) Votes:563,743 1.9% (+1.2%)

http://www.morningstaronline.co.uk/index.php/news/content/view/...

From the Horses Mouth!!
>
>> It is interesting to see that
>> New Labour was not good enough for the LibDems don't you think?
>
> It wasn't the answer, it wouldn't have produced a majority gov't, it
> was messy.

LOL!

> Best let them the socialist fake lib dems and Tories sell themselves
> out in a coalition.

They are up for it! New Labour/Labour wasn't.

> After they have finished with their cuts no one will vote for them,
> then Labour will be back in.

HAH! You wish! By that remark you imply that the ordinary Joe Soap is so
stupid that he doesn't realise that whatever party gets in will have to do a
hatchet job? Oh come *on*!

>
>> Apart from a full blown PR system, which would let in small parties
>> such as the BNP and UKip, this is a very good alternative.
>
> The BNP vote went down

Indeed it didn't. It is up by 1.2%! But that was FPTP.

>
>> Far be it for me to crow, but New Labour lost!! - As did *YOU* don
>> diddi!!! ROTFLMAO!
>>
>> We have gone away from the shallow, deceitfull, sneeringly Unionised,
>> non-government displayed for the last thirteen years.
>
> Enjoy it while you can ;-)

Oh, don't worry, I shall! :-))

--
Harry Merrick.

don diddi

5/17/2010 4:54:00 PM

0



"Harry Merrick" <homestud@hotmail.com> wrote in message
news:85cjifFs5iU1@mid.individual.net...
> don diddi wrote:
>> "Harry Merrick" <homestud@hotmail.com> wrote in message
>> news:852kc7Fur2U1@mid.individual.net...
>>> don diddi wrote:
>>>> "Harry Merrick" <homestud@hotmail.com> wrote in message
>>>> news:84v95eFjlU1@mid.individual.net...
>>>>> don diddi wrote:
>>>>>> On Sky News
>>>>>>
>>>>>> Liam Fox was expected to be Secretary of defence but it is
>>>>>> reported that Paddy Ashdown has that position.
>>>>>> Liam Fox is reported to be furious.
>>>>>>
>>>>>> Cameron already upsetting the backbenchers.
>>>>>>
>>>>>> lol
>>>>>
>>>>> You can rest assured that all these places have already been agreed
>>>>> and accepted within the negotiations.
>>>>
>>>> You mean stitched up behind the electorates back
>>>
>>> I don't think so. It was perfectly transparent.
>>
>> Funny, didn't see that on my ballot paper
>
> I presume you ballot paper is different to everyone elses then. It is
> perfectly normal practice to negotiate for a coalition with another party
> if there is a hung parliament.

So where is the transparency you are on about

Why would we, the hoi polloi, be involved in
> discussions such as those, which we do not understand or have the correct
> info for.
>
>>
>>>>
>>>>> So, your cozy conversations
>>>>
>>>> You sound jealous
>>>
>>> Not of you. I don't like sour grapes.
>>
>> Stating the facts isn't sour grapes
>
> It depends upon the nuances involved. Your's came through as sour grapes.
>
>>
>>>>> trying to
>>>>> sneer and smear the Coalition are as of nought! New Labour lost.
>>>>> The Pendulum has swung! Get used to it!
>>>>
>>>> Er, got some news for you, you may have missed it but the Tories
>>>> didn't win, hence the need for the socialist fake lib dems.
>>>
>>> The Tories had over 2 million votes MORE than New Labour!
>>> , So, whilst nobody actually won, New Labour was the worst loser!
>>
>> You missed your maths class I see
>
> Really? See this:
>
> Your guide to the poll results that matter
> Conservative: 307 seats (2005: 198) Votes:10,706,647 36% (+3.8%)
> Labour: 258 seats (2005: 356) Votes:8,604,358 29% (-6.2%)
> Lib Dem:57 seats (2005: 62) Votes:6,827,938 23%(+1.0%)
> DUP: 8 seats (2005: 9) Votes:168,216 0.6% (-0.3%)
> SNP: 6 seats (2005: 6) Votes:491,386 1.7% (+0.1%)
> Sinn Fein: 4 seats (2005: 5) Votes:171,942 0.6% (-0.1%)
> Plaid Cymru: 3 seats (2005: 2) Votes:165,394 0.6% (-0.1%)
> SDLP: 3 seats (2005: 3) Votes:110,970 0.4% (-0.1%)
> Green: 1 seats (2005: 0) Votes:285,616 1% (-0.1%)
> Alliance Party: 1 seats (2005: 0) Votes:42,762 (n/a)
> Ukip: 0 seats (2005: 0) Votes:917,832 3.1% (+0.9%)
> BNP: 0 seats (2005: 0) Votes:563,743 1.9% (+1.2%)
>
> http://www.morningstaronline.co.uk/index.php/news/content/view/...
>
> From the Horses Mouth!!
>>
>>> It is interesting to see that
>>> New Labour was not good enough for the LibDems don't you think?
>>
>> It wasn't the answer, it wouldn't have produced a majority gov't, it
>> was messy.
>
> LOL!
>
>> Best let them the socialist fake lib dems and Tories sell themselves
>> out in a coalition.
>
> They are up for it! New Labour/Labour wasn't.
>
>> After they have finished with their cuts no one will vote for them,
>> then Labour will be back in.
>
> HAH! You wish! By that remark you imply that the ordinary Joe Soap is so
> stupid that he doesn't realise that whatever party gets in will have to do
> a hatchet job? Oh come *on*!

No they aren't stupid, that's why they didn't give the Tories a majority ;-)


Harry Merrick

5/18/2010 3:59:00 PM

0

don diddi wrote:
> "Harry Merrick" <homestud@hotmail.com> wrote in message
> news:85cjifFs5iU1@mid.individual.net...
>> don diddi wrote:
>>> "Harry Merrick" <homestud@hotmail.com> wrote in message
>>> news:852kc7Fur2U1@mid.individual.net...
>>>> don diddi wrote:
>>>>> "Harry Merrick" <homestud@hotmail.com> wrote in message
>>>>> news:84v95eFjlU1@mid.individual.net...
>>>>>> don diddi wrote:
>>>>>>> On Sky News
>>>>>>>
>>>>>>> Liam Fox was expected to be Secretary of defence but it is
>>>>>>> reported that Paddy Ashdown has that position.
>>>>>>> Liam Fox is reported to be furious.
>>>>>>>
>>>>>>> Cameron already upsetting the backbenchers.
>>>>>>>
>>>>>>> lol
>>>>>>
>>>>>> You can rest assured that all these places have already been
>>>>>> agreed and accepted within the negotiations.
>>>>>
>>>>> You mean stitched up behind the electorates back
>>>>
>>>> I don't think so. It was perfectly transparent.
>>>
>>> Funny, didn't see that on my ballot paper
>>
>> I presume you ballot paper is different to everyone elses then. It is
>> perfectly normal practice to negotiate for a coalition with another
>> party if there is a hung parliament.
>
> So where is the transparency you are on about

We all knew a deal had to be srtuck. What that deal was had to be worked put
by the participants and was no business of ours until such times as the
terms were released. The transparency is that we knew a deal was being done,
and then, we knew what the deal was as soon as a deal was struck.

>
> Why would we, the hoi polloi, be involved in
>> discussions such as those, which we do not understand or have the
>> correct info for.
>>
>>>
>>>>>
>>>>>> So, your cozy conversations
>>>>>
>>>>> You sound jealous
>>>>
>>>> Not of you. I don't like sour grapes.
>>>
>>> Stating the facts isn't sour grapes

In your case it very clearly is!

>>
>> It depends upon the nuances involved. Your's came through as sour
>> grapes.
>>>
>>>>>> trying to
>>>>>> sneer and smear the Coalition are as of nought! New Labour lost.
>>>>>> The Pendulum has swung! Get used to it!
>>>>>
>>>>> Er, got some news for you, you may have missed it but the Tories
>>>>> didn't win, hence the need for the socialist fake lib dems.
>>>>
>>>> The Tories had over 2 million votes MORE than New Labour!
>>>> , So, whilst nobody actually won, New Labour was the worst loser!
>>>
>>> You missed your maths class I see
>>
>> Really? See this:
>>
>> Your guide to the poll results that matter
>> Conservative: 307 seats (2005: 198) Votes:10,706,647 36% (+3.8%)
>> Labour: 258 seats (2005: 356) Votes:8,604,358 29% (-6.2%)
>> Lib Dem:57 seats (2005: 62) Votes:6,827,938 23%(+1.0%)
>> DUP: 8 seats (2005: 9) Votes:168,216 0.6% (-0.3%)
>> SNP: 6 seats (2005: 6) Votes:491,386 1.7% (+0.1%)
>> Sinn Fein: 4 seats (2005: 5) Votes:171,942 0.6% (-0.1%)
>> Plaid Cymru: 3 seats (2005: 2) Votes:165,394 0.6% (-0.1%)
>> SDLP: 3 seats (2005: 3) Votes:110,970 0.4% (-0.1%)
>> Green: 1 seats (2005: 0) Votes:285,616 1% (-0.1%)
>> Alliance Party: 1 seats (2005: 0) Votes:42,762 (n/a)
>> Ukip: 0 seats (2005: 0) Votes:917,832 3.1% (+0.9%)
>> BNP: 0 seats (2005: 0) Votes:563,743 1.9% (+1.2%)
>>
>> http://www.morningstaronline.co.uk/index.php/news/content/view/...
>>
>> From the Horses Mouth!!
>>>
>>>> It is interesting to see that
>>>> New Labour was not good enough for the LibDems don't you think?
>>>
>>> It wasn't the answer, it wouldn't have produced a majority gov't, it
>>> was messy.
>>
>> LOL!
>>
>>> Best let them the socialist fake lib dems and Tories sell themselves
>>> out in a coalition.
>>
>> They are up for it! New Labour/Labour wasn't.
>>
>>> After they have finished with their cuts no one will vote for them,
>>> then Labour will be back in.
>>
>> HAH! You wish! By that remark you imply that the ordinary Joe Soap
>> is so stupid that he doesn't realise that whatever party gets in
>> will have to do a hatchet job? Oh come *on*!
>
> No they aren't stupid, that's why they didn't give the Tories a
> majority ;-)

You know the answer to that as well as I do! The Tories had a huge, massive
mountain to climb compared to anyone else. They ended up with far more seats
and far more votes than Labour, despite the fact that the constituency
boundaries were gerrymandered by Labour in Labours favour! After the
rip-offs perpetrated by Labour over thirteen long years and all the broken
promises during that period, I doubt Labour will get back for a very long
time. Oh, and to further answer your point, the voters actually wanted PR.
They have achieved the nearest thing to PR. But Labour lost!!
--
Harry Merrick.