This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // A Sample Map JSON object. | |
| { | |
| "_links": { | |
| "self": { "href": "/map" } | |
| }, | |
| "_embedded": { | |
| "locations": [{ | |
| "_links": { | |
| "self": { "href": "/purchase/trip/texas" }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Persistance | |
| class Trade < ActiveRecord::Base | |
| validates :item_id, :actor_id, presence: true | |
| def state | |
| super.to_s | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| config.to_prepare do | |
| Dir.entries("app/extensions") | |
| .select{ |f| !File.directory? f} | |
| .each do |file_name| | |
| array = file_name.split("_") | |
| array.pop | |
| klass_name = array.map(&:capitalize).join | |
| klass = klass_name.constantize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # app/extensions/school_extensions.rb | |
| module SchoolExtensions | |
| extend ActiveSupport::Concern | |
| included do | |
| end | |
| def address | |
| [street, suburb, state, postcode, country].join(', ') | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class School < ActiveRecord::Base | |
| has_many :students | |
| has_many :teachers | |
| def to_param | |
| "#{id}-#{name.parameterize}" | |
| end | |
| def to_s | |
| name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Api | |
| module V1 | |
| class AnswerController < ApplicationController | |
| respond_to :json | |
| def create | |
| lesson_session.process_attempts(params[:attempts].values) | |
| API::ProcessAnswer.new(lesson_session, current_student).call if lesson_session.completed? | |
| render json: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'test_helper' | |
| describe Lotus::Model::Adapters::FileSystemAdapter do | |
| before do | |
| TestUser = Struct.new(:id, :name, :age) do | |
| include Lotus::Entity | |
| end | |
| class TestUserRepository | |
| include Lotus::Repository |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ApplicationController < ActionController::Base | |
| # Prevent CSRF attacks by raising an exception. | |
| # For APIs, you may want to use :null_session instead. | |
| protect_from_forgery with: :exception | |
| before_action :authorize_user! | |
| protected | |
| def authorize_user! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class EventsController < ApplicationController | |
| def index | |
| @events = Event.all | |
| end | |
| def show | |
| @event = Event.find(params[:id]) | |
| end | |
| def new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AfterSignupController < ApplicationController | |
| include Wicked::Wizard | |
| steps :create_organization, :create_event, :create_tiers | |
| def show | |
| case step | |
| when :create_organization | |
| @form = Form::Organization.new(Organization.new) | |
| when :create_event | |
| @form = Form::Event.new(Event.new) |