On Dec 7, 11:10 am, Mathew Birch <[email protected]> wrote:
> Hi all,
>
> As part of a school project I need to set up an items collection which
> has categories and subcategories. I have used scaffolding to create
> these but when i edited the subcategory controller file by inserting
> this into the edit function: @category = Category.find_by_id(:all) and
> edited the model sub_category.rb to have the following line in it:
>
> belongs_to :category
>
> Now my problem is that when I now click the edit button it comes up with
> an error:
>
> TypeError in Sub_categories#edit
> Showing ItemCollection/app/views/sub_categories/_form.html.erb where
> line #1 raised:
>
> nil is not a symbol
> Extracted source (around line #1):
>
> 1: <%= form_for(@sub_category) do |f| %>

That suggests that @sub_category is nil. Is it?

Fred

> 2:   <% if @sub_category.errors.any? %>
> 3:     <div id="error_explanation">
> 4:       <h2><%= pluralize(@sub_category.errors.count, "error") %>
> prohibited this sub_category from being saved:</h2>
>
> I even removed my changes to those files and the error still appears.
> Anyone have any ideas what might be causing this?
>
> --
> Posted viahttp://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