Usergrid_ironhorse is based on Usergrid_iron and enables Ruby or Rails applications native Rails-style access to Apigee's App Services (aka Usergrid) REST API.
Usergrid_ironhorse is currently only compatible with Ruby on Rails 3.2.
Thus, if you are using Rails 4.x, you must use Usergrid_iron (the low-level API for Ruby). Alternatively, we would welcome your contributions to make Usergrid_ironhorse compatible with Rails 4.x. Thanks!
Add this line to your application's Gemfile:
gem 'usergrid_ironhorse'
And then execute:
$ bundle
Or install it yourself as:
$ gem install usergrid_ironhorse
Docs: https://usergrid.apache.org/docs/
Open source: https://github.com/usergrid/usergrid/
development: application_url: http://localhost:8080/my-organization/my-application client_id: YXA6BVYasLdNEeKBd1A2yYstg client_secret: YXA60Dnbzaxg1ObkE8ffsIxsGzsSo8 require_login: false test: application_url: http://localhost:8080/my-organization/my-application client_id: YXA6BVYasLdNEeKBd1A2yYstg client_secret: YXA60Dnbzaxg1ObkE8ffsIxsGzsSo8 require_login: false production: application_url: http://api.usergrid.com/my-organization/my-application client_id: YXA6BVYasLdNEeKBd1A2yYstg client_secret: YXA60Dnbzaxg1ObkE8ffsIxsGzsSo8 require_login: false
class Developer < Usergrid::Ironhorse::Base validates :name, :presence => true # Yes, of course you can use validation end
dev = Developer.new language: 'Ruby' dev.valid? # nope! dev.errors # {:name=>["can't be blank"]} dev.name = 'Scott' dev.save! dev = Developer.find_or_create_by_name 'Scott' dev.favorite_color = 'green' # assign new attributes automatically dev = Developer.find_by_name 'Scott'
User.as_admin do # do protected task end
Usergrid::Ironhorse::Base
and extend Usergrid::Ironhorse::UserContext
like so:class User < Usergrid::Ironhorse::Base extend Usergrid::Ironhorse::UserContext ... end
User.authenticate(username, password, session)
to login.User.clear_authentication(session)
to log out.before_filter :set_user_context def set_user_context User.set_context session end
helper_method :current_user def current_user User.current_user end
We welcome your enhancements!
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)We're shooting for 100% rspec coverage, so keep that in mind!
In order to run the tests, check out the Usergrid open source project (https://github.com/usergrid/usergrid/), build, and launch it locally.
(Note: If you change your local Usergrid settings from the default, be sure to update usergrid_ironhorse/spec/spec_settings.yaml to match.)
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. the ASF licenses this file to You under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.