tag:blogger.com,1999:blog-4937488729022245645.post8638149389934319475..comments2008-07-16T17:28:05.771-05:00Comments on Stochastic Bytes: param_accessibleChristopher J. Bottarohttp://www.blogger.com/profile/14116593743589959438noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-4937488729022245645.post-48063566114033134812008-07-16T17:28:00.000-05:002008-07-16T17:28:00.000-05:002008-07-16T17:28:00.000-05:00Heh, yeah... the plugin just plain wasn't working ...Heh, yeah... the plugin just plain wasn't working in a real app, even though all the tests were passing.<BR/><BR/>I rewrote the entire plugin and tests, as well as tested in a real app. Should be good to go now.Christopher J. Bottarohttp://www.blogger.com/profile/14116593743589959438noreply@blogger.comtag:blogger.com,1999:blog-4937488729022245645.post-26624384353977434672008-07-16T12:31:00.000-05:002008-07-16T12:31:00.000-05:002008-07-16T12:31:00.000-05:00Hi ChristopherI'm having a time getting this to wo...Hi Christopher<BR/><BR/>I'm having a time getting this to work, even on a new test app:<BR/><BR/>rails test_app; cd test_app; ./script/generate controller home; ./script/plugin install git://github.com/cjbottaro/param_protected.git<BR/><BR/>then in app/controllers/home.rb<BR/><BR/> param_protected :name<BR/><BR/> def index<BR/> render :text => "Hello %s" % param[:name]<BR/> end<BR/><BR/><BR/>Hitting http://localhost:3000/home?name=mina shows this in the browser:<BR/>Hello mina<BR/><BR/>Logging indicates that "name" was not protected:<BR/>Processing HomeController#index (for 127.0.0.1 at 2008-07-16 13:27:04) [GET]<BR/> Session ID: BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo<BR/>SGFzaHsABjoKQHVzZWR7AA==--2b265f2ec8b10c2c878a44bd512a2012e8148e7e<BR/> Parameters: {"name"=>"mina", "action"=>"index", "controller"=>"home"}<BR/> Parameters protected: {}<BR/><BR/>Digging through the plugin source, I think the problem is in _pp_get_actions, specifically, calling public_instance_methods<BR/><BR/>At the time the method in my controller gets called, the "index" method has not yet been defined, so the above code doesn't assign anything to _pp_protected_map<BR/><BR/>I've tried this with older versions of rails instead of 2.1 and it's the same behavior.<BR/><BR/>Any ideas ?minaguibhttp://mina.naguib.ca/noreply@blogger.comtag:blogger.com,1999:blog-4937488729022245645.post-77262068588807107712008-07-16T08:41:00.000-05:002008-07-16T08:41:00.000-05:002008-07-16T08:41:00.000-05:00Just in time for my current rails project. Thank ...Just in time for my current rails project. Thank you :)minaguibhttp://mina.naguib.ca/noreply@blogger.com