How to disable access control in migrations ?

62 views
Skip to first unread message

Douglas Magnenat

unread,
Jun 11, 2013, 4:02:39 AM6/11/13
to declarative_...@googlegroups.com

Hello,

I need to disable access control in my migration, because I enforced model security with "using_access_control" option in my models.
So I managed to put my migration block into a "without_access_control" method block :

class AddDateToProjMesure < ActiveRecord::Migration

  def change
    add_column :proj_mesures, :date_reference, :date

    Authorization::Maintenance::without_access_control do

  ProjMesure.all.each do |proj_mesure| proj_mesure.update_attributes! :date_reference => Time.zone.today end # ProjMesure.all.each

 end # Authorization::Maintenance::without_access_control end end


However, I still got the following error :

    uninitialized constant Authorization::Maintenance/var/www-opf/opf/db/migrate/20130607103809_add_date_to_proj_mesure.rb:41:in `change'
 

How can I have access to this public method without_access_control ?


Thanks for any help

Langhorst, Brad

unread,
Jun 11, 2013, 6:58:26 AM6/11/13
to <declarative_authorization@googlegroups.com>
I think you're mising a require…  the maintenance stuff is not available by default in migrations.

require 'declarative_authorization/maintenance'

Authorization::Maintenance::without_access_control do
end

works for me.


Brad
--
You received this message because you are subscribed to the Google Groups "declarative_authorization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to declarative_author...@googlegroups.com.
To post to this group, send email to declarative_...@googlegroups.com.
Visit this group at http://groups.google.com/group/declarative_authorization?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
Brad Langhorst
Applications and Product Development Scientist







Douglas Magnenat

unread,
Jun 11, 2013, 8:40:42 AM6/11/13
to declarative_...@googlegroups.com
Great ! You are my hero !

As mentioned int he API doc  I tried  :

require "vendor/plugins/declarative_authorization/lib/maintenance"

But it was not working.

You got it ! (Though I don't understand why it is working)

Many Thanks !

Edward Rudd

unread,
Jun 11, 2013, 9:55:15 AM6/11/13
to Douglas Magnenat, declarative_...@googlegroups.com
This is because of the require path in ruby.   so declarative_authorization/maintenance will load out f that path.. 

also, do realize that vendor plugins are deprecated in rails and will not be supported in rails 4.

--
You received this message because you are subscribed to the Google Groups "declarative_authorization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to declarative_author...@googlegroups.com.
To post to this group, send email to declarative_...@googlegroups.com.
Visit this group at http://groups.google.com/group/declarative_authorization?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Edward Rudd
OutOfOrder.cc
Skype: outoforder_cc






Douglas Magnenat

unread,
Jun 11, 2013, 4:26:30 PM6/11/13
to declarative_...@googlegroups.com
Yes of course, i understand the require statement.
The point is why there is no folder prefix in front of 'declarative_authorization', and how does Rails know where to look for ? ^^

Good night
Douglas


Brad Langhorst
wrote :

Edward Rudd

unread,
Jun 12, 2013, 8:32:50 PM6/12/13
to declarative_...@googlegroups.com
I'm pretty sure that rails adds in the "vendor plugins" to the search path.

--
You received this message because you are subscribed to the Google Groups "declarative_authorization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to declarative_author...@googlegroups.com.
To post to this group, send email to declarative_...@googlegroups.com.
Visit this group at http://groups.google.com/group/declarative_authorization?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages