i am very new with handling Ruby on Rails, so i did the Video-Tutorial
of “video2brain”.
They use an older Version of Rails (1.8… - i guess) and in an
controller-file they want me to do the following:
class FormController < ApplicationController
def index @form = Form.find(:first) @form.update_attributes(params[:form])
I added the S - and so the fault report changed to: undefined method
`details’ for #Form:0x8917af0 (just the S in details is new in this
error message). Cant be the Solution
belond_to and has one in your models?
This database has a table called “forms” and a table called “details”
but there is no detail field in the “forms”-table.
So i need to create this field, correct?
No, I think it is more likely that you need to setup a relationship
between the tables so that form has_many details. This should all be
in the tutorial however.
I think you might be much better finding a tutorial for the version of
rails you are using however. If it is out of date you will forever be
coming up against problems.
ooooh wait , is a one to one relation chip, do you have
I think you might be much better finding a tutorial for the version of
rails you are using however. If it is out of date you will forever be
coming up against problems.
I would start by looking at the Rails Guides (google it) andhttp://railstutorial.org/is good.
Colin
Thanks for that advice. But i really want to finish this chapter of
the tutorial -
So could you (or someone else) tell me, why this error message appears
and what i need to do to go on?
On 23 September 2010 08:32, Sven W. [email protected] wrote:
Is there a ‘detail’ field in the forms table?
between the tables so that form has_many details. This should all be
Thanks for that advice. But i really want to finish this chapter of
the tutorial -
So could you (or someone else) tell me, why this error message appears
and what i need to do to go on?
As I said I think it is likely that you should have setup a
relationship between the models. You may have missed something in the
tutorial (or the tutorial is missing details).
exactly acting like the “video2brain”-tutorial …
So i need to create this field, correct?
Colin
… The tutorial is missind details - F***!
Maybe you could explain to me how to setup a relationship between the
models? Otherwise i will google or do an other tutorial…
Thank you so far
That is what I suggested in the first place, to quote myself:
I would start by looking at the Rails Guides (google it) and http://railstutorial.org/ is good.
I would suggest that you use Rails 3 if you are not already doing so
as it is now the current version, though it is still very new, so
those who will try to help you are still learning themselves.
There is a Rails Guide specifically on ActiveRecord Relationships but
I would start with Getting Started.
On 23 September 2010 08:32, Sven W. [email protected] wrote:
Is there a ‘detail’ field in the forms table?
between the tables so that form has_many details. This should all be
Thanks for that advice. But i really want to finish this chapter of
the tutorial -
So could you (or someone else) tell me, why this error message appears
and what i need to do to go on?
As I said I think it is likely that you should have setup a
relationship between the models. You may have missed something in the
tutorial (or the tutorial is missing details).
Colin
… The tutorial is missind details - F***!
Maybe you could explain to me how to setup a relationship between the
models? Otherwise i will google or do an other tutorial…
Thank you so far
exactly acting like the “video2brain”-tutorial …
So i need to create this field, correct?
I would start by looking at the Rails Guides (google it) andhttp://railstutorial.org/is good.
I would suggest that you use Rails 3 if you are not already doing so
as it is now the current version, though it is still very new, so
those who will try to help you are still learning themselves.
There is a Rails Guide specifically on ActiveRecord Relationships but
I would start with Getting Started.
Colin
I dont use Rail 3, but 1.8.6 - because the Autor of the Tutorial used
that Version, too.
Would you recommend to use the 2. or the 3. Version?
IIRC, given the code above as the main clue, you might need:
class form < ActiveRecord::Base
a form model has a related detail model
has_one :detail
end
class detail < ActiveRecord::Base
and vice-versa
belongs_to :form
end
The details table needs to have a column named form_id, spec’ed as
integer, the forms table gets no additional field.
If there can be more than one detail model related to a form, then just
the form model specification changes… it notes has_many, and the
related model is pluralized.
Thanks! That was almost successful …I used the “has_one” -command and
deleted the following line in form_controller.rb:
“@detail.update_attributes(params[:detail])”.
Actually i can see two boxes - the second one is the “detail”-box.
the first one saves my changes. the detail-box does not.
Pasting the “@detail.update_attributes(params[:detail])” -line into
the form_controller.rb , the following error message appears:
" NoMethodError in FormController#index
You have a nil object when you didn’t expect it!
You might have expected an instance of ActiveRecord::Base.
The error occured while evaluating nil.update_attributes"
Whats wrong? And Thank you very very very (!) much for your help -
thats awesome to get help by friendly people :]