Hello everyone,
I''ve decided to take the step into creating a mini-forum for my
website where users can open new posts on exixting topics and allow
people to discuss things etc...
I am following a tutorial in the book: APRESS - Practical Rails Social
Networking Sites and have hit a minor issue.
Part of the Forum requirements is to add a moderator role to allow
only certain individuals the ability to manage topics etc.
That code is in the moderator_role.rb migration file which looks like
this:
class AddModeratorRole < ActiveRecord::Migration
def self.up
moderator_role = Role.create(:name => ''Moderator'')
admin_user = User.find_by_username(''Admin'')
admin_user.roles << moderator_role
end
def self.down
moderator_role = Role.find_by_name(''Moderator'')
admin_user = User.find_by_username(''Admin'')
admin_user.roles.delete(moderator_role)
moderator_role.destroy
end
end
WHen i run rake db:migrate I get the following error:
== AddModeratorRole: migrating
==============================================rake aborted!
An error has occurred, all later migrations canceled:
uninitialized constant AddModeratorRole::Role
I''m not too sure what''s wrong as I''ve followed the
book so far to the
word.
ANy ideas, help on how to resolve this would be really appreciated.
Many Thanks
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On 8 May 2010 09:55, RubyonRails_newbie <craigwesty79-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hello everyone, > > I''ve decided to take the step into creating a mini-forum for my > website where users can open new posts on exixting topics and allow > people to discuss things etc... > > I am following a tutorial in the book: APRESS - Practical Rails Social > Networking Sites and have hit a minor issue. > > Part of the Forum requirements is to add a moderator role to allow > only certain individuals the ability to manage topics etc. > > That code is in the moderator_role.rb migration file which looks like > this: > > class AddModeratorRole < ActiveRecord::Migration > def self.up > moderator_role = Role.create(:name => ''Moderator'') > admin_user = User.find_by_username(''Admin'') > admin_user.roles << moderator_role > end > def self.down > moderator_role = Role.find_by_name(''Moderator'') > admin_user = User.find_by_username(''Admin'') > admin_user.roles.delete(moderator_role) > moderator_role.destroy > end > end > > > WHen i run rake db:migrate I get the following error: > > == AddModeratorRole: migrating > ==============================================> rake aborted! > An error has occurred, all later migrations canceled: > > uninitialized constant AddModeratorRole::RoleHave you accidentally missed out a step that creates the roles table? Colin -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks for the reply COlin, Yes i''d missed that. All sorted now. Thanks for that! On 8 May, 11:46, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 8 May 2010 09:55, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > > > Hello everyone, > > > I''ve decided to take the step into creating a mini-forum for my > > website where users can open new posts on exixting topics and allow > > people to discuss things etc... > > > I am following a tutorial in the book: APRESS - Practical Rails Social > > Networking Sites and have hit a minor issue. > > > Part of the Forum requirements is to add a moderator role to allow > > only certain individuals the ability to manage topics etc. > > > That code is in the moderator_role.rb migration file which looks like > > this: > > > class AddModeratorRole < ActiveRecord::Migration > > def self.up > > moderator_role = Role.create(:name => ''Moderator'') > > admin_user = User.find_by_username(''Admin'') > > admin_user.roles << moderator_role > > end > > def self.down > > moderator_role = Role.find_by_name(''Moderator'') > > admin_user = User.find_by_username(''Admin'') > > admin_user.roles.delete(moderator_role) > > moderator_role.destroy > > end > > end > > > WHen i run rake db:migrate I get the following error: > > > == AddModeratorRole: migrating > > ==============================================> > rake aborted! > > An error has occurred, all later migrations canceled: > > > uninitialized constant AddModeratorRole::Role > > Have you accidentally missed out a step that creates the roles table? > > Colin > > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.