I have resolved this problem with ruby logic, but still waiting for some good logic.
Solution
url = @browser.url
#> ["localhost:3000/sites/535/ecosystem/new"]
uri = url.split("/sites/")
#> ["localhost:3000", "535/ecosystem/new"]
uri = uri[1].split("/ecosystem/new")[0]
#> "535"
I can now access id
i.e 535
in current url. But still wating for some good logic for resolving this issue.
Thanks