So I''m working on creating a migration for a new version of one of the
projects I''m working on. But Rake seems to be selectively spitting out
errors. The same code that works only a few lines up will not work
where I most need it. (That should be a law of programming...)
So here''s what''s up. I''ve got a table that stores
information on the
roles that users can have. There are four columns: id, name,
parent_id, and list_priority. The big key feature that I''m
implementing in this release is the concept of permission inheritance
across roles. So, what I''ve done for some roles is the following:
puts '' -> Remove developer permissions collection''
@developerRole.permissions.delete_all
puts '' -> Set developer parent and list_priority''
@developerRole.update_attributes(:parent_id =>
@officerRole.id, :list_priority => 5)
The migration handles that fine. However it throws an error on:
@serviceChair = Role.create :name => ''Service Chair''
@serviceChair.update_attributes(:parent_id =>
@brotherRole.id, :list_priority => 3)
@serviceChair.permissions << @op_login
@serviceChair.permissions << @op_service_fundraising
The rake error reads as follows:
rake aborted!
undefined method `list_priority='' for #<Role id: 5, name:
"Service
Chair">
And, if I remove list_priority from the update_attributes method in
the second code segment, it will throw a similar error about
parent_id. Could anyone tell me what the heck is going on here? I''m
about at the end of my wits trying to figure this out.
Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Matt wrote:> puts '' -> Remove developer permissions collection'' > @developerRole.permissions.delete_all > puts '' -> Set developer parent and list_priority'' > @developerRole.update_attributes(:parent_id => > @officerRole.id, :list_priority => 5) > > The migration handles that fine. However it throws an error on: > > @serviceChair = Role.create :name => ''Service Chair'' > @serviceChair.update_attributes(:parent_id => > @brotherRole.id, :list_priority => 3) > @serviceChair.permissions << @op_login > @serviceChair.permissions << @op_service_fundraising >What (if any) is in between those two sections ? Are you changing the roles table in this migration ? Where does @developerRole come from ? Fred --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The Roles table is being changed in this migration, but I alter the
table before I start working with the data. The two code blocks are
adjacent. The @developerRole code is immediately above it, and
@developerRole is created by
@developerRole = Role.find(:first, :conditions => {:name =>
''Developer''})
Which happens immediately after the table alterations.
On Dec 27, 8:24 pm, Frederick Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Matt wrote:
> > puts '' -> Remove developer permissions
collection''
> > @developerRole.permissions.delete_all
> > puts '' -> Set developer parent and
list_priority''
> > @developerRole.update_attributes(:parent_id =>
> > @officerRole.id, :list_priority => 5)
>
> > The migration handles that fine. However it throws an error on:
>
> > @serviceChair = Role.create :name => ''Service
Chair''
> > @serviceChair.update_attributes(:parent_id =>
> > @brotherRole.id, :list_priority => 3)
> > @serviceChair.permissions << @op_login
> > @serviceChair.permissions << @op_service_fundraising
>
> What (if any) is in between those two sections ? Are you changing the
> roles table in this migration ? Where does @developerRole come from ?
>
> Fred
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@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
-~----------~----~----~----~------~----~------~--~---
In case you are modifying the Roles table (and then updating the new fields) you might want to reset the column information. ModelName.reset_column_information ModelName is your case might be Role. -- Shiv On Sun, Dec 28, 2008 at 10:53 AM, Matt <matt.foxtrot-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > The Roles table is being changed in this migration, but I alter the > table before I start working with the data. The two code blocks are > adjacent. The @developerRole code is immediately above it, and > @developerRole is created by > > @developerRole = Role.find(:first, :conditions => {:name => > ''Developer''}) > > Which happens immediately after the table alterations. > > On Dec 27, 8:24 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Matt wrote: > > > puts '' -> Remove developer permissions collection'' > > > @developerRole.permissions.delete_all > > > puts '' -> Set developer parent and list_priority'' > > > @developerRole.update_attributes(:parent_id => > > > @officerRole.id, :list_priority => 5) > > > > > The migration handles that fine. However it throws an error on: > > > > > @serviceChair = Role.create :name => ''Service Chair'' > > > @serviceChair.update_attributes(:parent_id => > > > @brotherRole.id, :list_priority => 3) > > > @serviceChair.permissions << @op_login > > > @serviceChair.permissions << @op_service_fundraising > > > > What (if any) is in between those two sections ? Are you changing the > > roles table in this migration ? Where does @developerRole come from ? > > > > Fred > > >-- George Carlin - "Weather forecast for tonight: dark." --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That fixed my problem! Thanks! On Dec 28, 1:15 am, "Shiv N Gautam" <s.n.gau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> In case you are modifying the Roles table (and then updating the new fields) > you might want to reset the column information. > > ModelName.reset_column_information > > ModelName is your case might be Role. > > -- > Shiv > > > > On Sun, Dec 28, 2008 at 10:53 AM, Matt <matt.foxt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > The Roles table is being changed in this migration, but I alter the > > table before I start working with the data. The two code blocks are > > adjacent. The @developerRole code is immediately above it, and > > @developerRole is created by > > > @developerRole = Role.find(:first, :conditions => {:name => > > ''Developer''}) > > > Which happens immediately after the table alterations. > > > On Dec 27, 8:24 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > Matt wrote: > > > > puts '' -> Remove developer permissions collection'' > > > > @developerRole.permissions.delete_all > > > > puts '' -> Set developer parent and list_priority'' > > > > @developerRole.update_attributes(:parent_id => > > > > @officerRole.id, :list_priority => 5) > > > > > The migration handles that fine. However it throws an error on: > > > > > @serviceChair = Role.create :name => ''Service Chair'' > > > > @serviceChair.update_attributes(:parent_id => > > > > @brotherRole.id, :list_priority => 3) > > > > @serviceChair.permissions << @op_login > > > > @serviceChair.permissions << @op_service_fundraising > > > > What (if any) is in between those two sections ? Are you changing the > > > roles table in this migration ? Where does @developerRole come from ? > > > > Fred > > -- > > George Carlin - "Weather forecast for tonight: dark."--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---