destroy_permitted? not working with a new database

35 views
Skip to first unread message

tomkins

unread,
Aug 22, 2012, 9:29:31 AM8/22/12
to hobo...@googlegroups.com
I uploaded a different database that has the same structure but different data than the old database, and the remove button in a table has stopped working. It removes the item from the table but when I refresh the page it returns. I looked into the logs and I can see Hobo: Permission Denied!
This is my destroy_permitted? function:
  
  def destroy_permitted?
    acting_user == user or acting_user.administrator? 
  end

When I change the acting user to administrator it works, but when the acting user == user it gives Permission Denied, which it did not do with the old database.

Thanks.

tomkins

unread,
Aug 22, 2012, 9:45:59 AM8/22/12
to hobo...@googlegroups.com
I forgot to mention, I have a table called access-roles that contains the rights for each type of user, and that data hasn't changed, only the data in the other tables.

Bryan Larsen

unread,
Aug 23, 2012, 1:58:15 PM8/23/12
to hobo...@googlegroups.com
I prefer to use acting_user.id == user.id instead of acting_user ==
user. The way that rails works it isn't necessarily guaranteed that
two elements that occupy the same row in the database necessarily end
up instantiated as the same object, especially since acting_user may
have come from your session instead of the database.

Bryan
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/Hq83iyGMlK0J.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to
> hobousers+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.

tomkins

unread,
Aug 24, 2012, 6:34:53 AM8/24/12
to hobo...@googlegroups.com
Yes, I think acting_user was coming from a session, it's solved now.
Thanks.
Reply all
Reply to author
Forward
0 new messages