Ruby On Rails Problems

Ive posted the following on various forums and had no reply, and was
told this was the place were i could get an answer:

Hi, As you may know I currently own and maintain dev-hq.co.uk, and
basically ive been trying to "convert" everythig to RoR as ive been
told this could benifit me in many ways. I asked a friend who is good
in RoR to help me, and we managed to create an application which does
basically everything its supposed to. However just before finishing
the project he got bored of helping me time and time again, so there
are some unfinished bits which I was hoping you could help with. First
off im going to talk about an error I get when trying to edit/create
new tutorials in a certain catagory. This is the error I get:

Category(#47881910) expected, got String(#32601110)

Ive looked everywhere for this and cant find a fix that works. Now
because I dont want to have to post things I dont need too, Im just
going to post the thing that I put in new and edit to get the catagory
box to appear (on creation or edit its looking for the catagory number
by the way):

  <p>
    <%= f.label :category_id %>
    <%= f.text_field :category_id %>
  </p>

So that is my first problem. Secondly since im classed even lower than
bad in RoR I dont know how I make the tutorials in different
catagories apear on the catagories page.. If anyone knows how to do
this please tell me.

Last of all, This is a feature which was not even started yet, next to
the names of the tutorials on the catagory display page I want to
display the ammount of tutorials there are in that section in
brackets, and then have the catagories sorted on the catagory page by
ammount of tutorials.

I know I have alot to ask, but please help guys..

PS: Sorry for the kind of unhelpful topic title, This topic is asking
for so much I didnt know what to name it.

Thanks In Advance,

Joe

I suggest spending a couple of days going through the Railscasts by
Ryan Bates, especially those related to models, relationships and
forms.

This is probably the part where we ask if you can archive the app and
put it somewhere where we can download it; this is all quite vague.

The first error message means it expects an Object of class Category,
and instead it sees an object of class String.

This also sounds like you've never touched Rails in your life, and your
friend wasn't "helping" but "coding" and probably "fixing" for you :slight_smile:

If you are not familiar with Ruby, go through a basic Ruby tutorial.
For a good Rails intro, go through
http://www.buildingwebapps.com/learningrails .

Is the category_id datatype a string rather than an integer? Check
your migrations.

-eric

No, the problem is that in his form_for he didn’t pass in a Category object, but a string.

form_for :category do |f|

@category should exist and be a Category model instance. The error pops up because the variable there apparently is just a string.

Acctually it was just because I had another variable called catagory.
Soz i took so long to reply.

Ive basically sorted all out now (by myself thank you very much), soz
for wasted thread.

Thanks,

Joe

Oh, and btw, those railscasts did really help!!!! (although I didnt
yet see this reply to the thread when I was chekin em out)