Michael Pavling wrote in post #1035550:
> On 7 December 2011 11:39, Mathew Birch <[email protected]> wrote:
>> That was probably the problem since @sub_category was being set to
>> SubCategory.find_by_id... so I will try and create it again and now just
>> have it as one word to avoid confusion.
>
> It's not being set to "SubCategory.find_by_id", it's being set to the
> result of the expression "SubCategory.find_by_id(:all)", which doesn't
> seem to me to be likely to return any records, as ":all" is a Symbol,
> and find_by_id would probably expect an integer ID or array of
> integers.

I re-scaffolded everything and now the class that used to be called 
sub_category is now just subcategory. The same error appears as in my 
first post. And the following is the inside of the edit function in the 
subcategories_controller:

@subcategory = Subcategory.find_by_id(params[:id])
@category = Category.find(:all)

the model file (subcategory.rb):
class Subcategory < ActiveRecord::Base
  belongs_to :category
end

Any advice?

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to