Basically I've been creating various RoR (ruby on rails) applications
and I cant figure out how to add properties to an already existing
scaffold; I have ended up destroying and messing up two projects that
I've worked hard on so far in trying to do this and realised I need
some help trying to edit these.
For example if I created a forum with RoR and decided to have a forum,
thread, and post scaffold, and they each has their own properties;
Lets say the forum scaffold was made with these parameters "forum
name:string number:integer". However if I wanted to add another
property to the forum scaffold (for example if I wanted to add
"password:string") how would I do this?
At the moment I have something similar to this (well its different,
but never the less uses scaffolds kind of like this) and I need to add
a new property. Ive tried creating over the top of it with its already
existing parameters plus the ones I want to add (for example "forum
name:string number:integer password:string") however when I do this I
then get this error when I attempt to migrate the database (categories
is the scaffold I'm trying to add properties to):
rake aborted!
An error has occurred, this and all later migrations canceled:
You've got some terminology problems there, that are confusing things
a little. What you're calling "scaffolds" are really "migrations".
"Scaffolding" is the combination of views, migrations, models and
controllers that Rails can create for you to give you a bootstrap into
a working application.
By the sounds of it, you need to use "add_column" in your new migration.
Have a look at some of the resources found through Google, or at p.71
of the "Agile Web Development With Rails" book.
http://www.google.co.uk/search?q=rails+migration+add_column
Aha, thanks! ill look into this (I really dont know any of the
terminology, when I created the stuff I saw the word scaffold and
assumed this was what to call it :P)
Aha, thanks! ill look into this (I really dont know any of the
terminology, when I created the stuff I saw the word scaffold and
assumed this was what to call it :P)
So first of all with these things, can I just change it in db/migrate/
WhateverFile.rb ?
Then when I have changed it how do I put these changes into action?
Also I cant seem to find how this could help me solve the error:
rake aborted!
An error has occurred, this and all later migrations canceled:
So first of all with these things, can I just change it in db/migrate/
WhateverFile.rb ?
Then when I have changed it how do I put these changes into action?
Also I cant seem to find how this could help me solve the error:
rake aborted!
An error has occurred, this and all later migrations canceled:
So first of all with these things, can I just change it in db/migrate/
WhateverFile.rb ?
Then when I have changed it how do I put these changes into action?
Also I cant seem to find how this could help me solve the error:
rake aborted!
An error has occurred, this and all later migrations canceled:
So first of all with these things, can I just change it in db/migrate/
WhateverFile.rb ?
Then when I have changed it how do I put these changes into action?
Also I cant seem to find how this could help me solve the error:
rake aborted!
An error has occurred, this and all later migrations canceled:
I suggest you have a look at the rails guides at
http://guides.rubyonrails.org/. Start with Getting Started, not
surprisingly, then the next one is Database Migrations which should
sort out your current problems. Then move on and work you way through
the others.
The ones on ActiveRecord Associations and Debugging are compulsory reading.
NEVER MIND. I was being an idiot. I just deleted the old migration
file that was causing the problems; and then created a new migration
file to get the new stuff in..