4

This controller action worked perfectly in Rails 2.3.x:

def show
  @title = Tag.find(params[:id]).name
  @tag = Tag.find(params[:id])
  @messages = Post.paginate(Post.find_tagged_with(@tag), 
              :page => params[:page], :per_page => 10, :order => "updated_at DESC")
  @related_tags = @related_entries.collect{|x|x.tags}.flatten.uniq
  @related_tags.delete(@tag)
end

But while migrating my application to Rails 3 I run into this error in Tags#show:

uninitialized constant TagsController::Tag

It's not liking the Tag constant. Has anyone else had this issue?

I'm using Rails 3.0.0RC and Ruby 1.9.2.

66tree
  • 579
  • 7
  • 29

2 Answers2

12

Try including the complete namespace e.g.

@title = ActsAsTaggableOn::Tag.find(params[:id]).name
Paul Groves
  • 3,983
  • 2
  • 23
  • 24
10

You can also define the model in your app:

# app/models/tag.rb
class Tag < ActsAsTaggableOn::Tag
end

# app/models/tagging.rb
class Tagging < ActsAsTaggableOn::Tagging
end
Andy
  • 1,801
  • 3
  • 22
  • 33