This is a class (re)loading problem. For all sorts of people in the
same boat (and a few solutions), see
http://dev.rubyonrails.org/ticket/8246 .

I expect you'll only be able to make this happen in dev mode. What
plugins do you have installed?

For a simple solution, try adding:

config.to_prepare do
  require_dependency "ingredient"
end

In your environment.rb's "Rails::Initializer.run()" block.


~ j.



On 3/5/08, Harro <[EMAIL PROTECTED]> wrote:
>
> This has stumped everyone in the IRC channel, I wonder if anyone here
> knows whats going on.
>
> Heres the problem posted on pasite: http://pastie.caboo.se/161938
> Or in plain text below.
>
> Thanks for any help.
>
>
> ## UPDATE [plain_text]
>
> Chnaged both too HABTM and entered this into the console:
>
> >> s = Sandwich.find(:first)
> #<Sandwich id: 1, name: "Egg Salad", cost: 2>
> >> i = Ingredient.find(:first)
> #<Ingredient id: 1, item: "Butter", stock: 1500, stock_warn: 500>
> >> s.ingredients << i
> ActiveRecord::AssociationTypeMismatch: Ingredient expected, got
> Ingredient
>
> ## [plain_text]
>
> Trying to created a many to many relationship between ingredients and
> sandwiches. So that each sandwich
> can have many ingredients and the ingredients can be on many
> sandwiches.
>
> ## Join Table
>
> class AddSandwichJoinTable < ActiveRecord::Migration
>   def self.up
>     create_table :ingredients_sandwiches, :id => false, :force => true
> do |t|
>       t.integer  :ingredient_id
>       t.integer  :sandwich_id
>     end
>   end
>
>   def self.down
>   end
> end
>
> ## Ingredient Model
>
> class Ingredient < ActiveRecord::Base
>   has_and_belongs_to_many :sandwiches
> end
>
> ## Sandwich Model
>
> class Sandwich < ActiveRecord::Base
>   has_and_belongs_to_many :ingredients
> end
>
> ## Console [plain_text]
>
> I used the console to create and assign a var to a sandwich and an
> ingredient.
> But it throws up errors if i try to do such things as:
>
> s.ingredients << i
>
> (Where s is the sandwich and i is the ingredient)
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Heroku" 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/heroku?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to