fixes in profiles views and controllers, add state_machine gem and a fix for support in rails 4.1