Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jonas Eriksson 930 posts 1825 karma points
    Jun 10, 2011 @ 10:28
    Jonas Eriksson
    0

    the Document api from Ruby "wrong number of arguments"

    Any IronRuby-ninjas out there? I'm trying to use the Document class to change properties for existing documents, but IronRuby does not seem to handle the constructor overload for integer (as document id) (?)

    $LOAD_PATH << "C:\\inetpub-dev\\dev.mysite.com\\bin"
    require "cms.dll"
    require "businesslogic.dll"
    
    web = Object.const_get("umbraco").const_get("cms").const_get("businesslogic").const_get("web")
    existing_document_id = 1065
    existing_document = web::Document.new(existing_document_id)

    If I omit the id from the last row I can run my script, but I want to use an existing document and therefore I use the id.

    I get the error:

    wrong number of arguments (1 for 0)

  • Jonas Eriksson 930 posts 1825 karma points
    Jun 12, 2011 @ 19:58
    Jonas Eriksson
    0

    I put the question at StackOverflow aswell, http://stackoverflow.com/questions/6310599/problem-to-instantiate-object-with-overloaded-constructor-in-ironruby/ ; the solution was to call clr_new instead of new, as there was already a New method on the Document class. Yay!

    the whole code snippet is quite long for such an easy task, but it would be very easy to place some commonly used requires in a "global.rb" or something and then just keep the necessary files.

    Why am I doing this? Well I'm having a simple RubyPad in my Umbraco backend and with the help of it I can now run some cleanup scripts for all kinds of node "housekeeping". RubyPad is simply two textareas, executing ruby code in one of them and displaying the result in the other.

Please Sign in or register to post replies

Write your reply to:

Draft