acts as ruby
A quick and dirty, dangerous and dumb, funny and very unsecure debugging idea for Rails controllers.
Lets say you want to be able to arbitrarily see the value of a variable in your controller action without going into the debugger or changing your templates. What if you just passed some ruby code in the url?
asdfs_controller.rb
def show
@asdf = Asdf.find(params[:id])
if (params[:ruby])
return( render :text => eval(params[:ruby]) )
end
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @asdf }end
end
Then you could put in your url things like:
http://0.0.0.0:3000/asdfs/1?ruby=@asdf.name
http://0.0.0.0:3000/asdfs/1?ruby=@asdf.class
http://0.0.0.0:3000/asdfs/1?ruby=self.inspect
http://0.0.0.0:3000/asdfs/1?ruby=Asdf.find(:all).size.to_s




acts as ruby
Posted by: robinhoode on September 21, 2007 02:44 AM#