Ridesharing is attracting more and more attention due to its high potential for applying new business models to private transportation in urban areas, reducing the greenhouse gas emissions and decreasing the amount of traffic on the streets. The paper extends the earlier presented approaches of building sustainable logistics system that support ridesharing by applying to it principles of smart spaces, where various electronic devices can seamlessly access all required information distributed in the multi-device system and all services are provided in pro-active manner. In particular, the paper describes the ontology and major components for the ridesharing system. An example implementation of the developed solution was done on top of Smart-M3 open source platform.