Forum: Ruby on Rails Run code on application launch

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aaf9d67916c3c07e43a20e5e885f757b?d=identicon&s=25 Asa Hopkins (asa)
on 2006-01-07 20:44
I have some fields that set up a HABTM relationship (permissions for an
access control list for users) that need to pair user roles with
permissions, and I'd like to not have to set it up manually in the
database.  Instead, I'd like to just say things like:

unless role.permissions.include?("controller/action")
    role.permissions<<"controller/action"
end

This way I can change the permission structure from ruby, rather than
having to go to the DB.  Also, DB schemas (eg for migrations) aren't
going to carry my carefully selected table contents with them.

I only want to run this once, when the application starts.  So, where do
I put this code?

Thanks,
Asa
This topic is locked and can not be replied to.