Sha256: c151933a5fd8885f8077be12be6451b2b082dee41df212ae9206856c3946561f

Contents?: true

Size: 977 Bytes

Versions: 14

Compression:

Stored size: 977 Bytes

Contents

class UsersController < ApplicationController
  rescue_from ROM::Rails::RelationParamsMissingError do
    head :bad_request
  end

  def index
    render :index, locals: { users: rom.relation(:users).as(:entity) }
  end

  def search
    render :index, locals: {
      users: rom.relation(:users).as(:entity).by_name(params[:name])
    }
  end

  def new
    render :new, locals: { user: NewUserForm.build }
  end

  def create
    user_form = NewUserForm.build(params[:user]).save

    if user_form.success?
      redirect_to :users
    else
      render :new, locals: { user: user_form }
    end
  end

  def edit
    user_form = UpdateUserForm.build({}, { id: params[:id] })

    render :edit, locals: { user: user_form }
  end

  def update
    user_form = UpdateUserForm.build(params[:user], id: params[:id]).save

    if user_form.success?
      redirect_to :users
    else
      render :edit, locals: { user: user_form }
    end
  end

  def ping
    head :ok
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rom-rails-0.9.0 spec/dummy/app/controllers/users_controller.rb
rom-rails-0.9.0.beta1 spec/dummy/app/controllers/users_controller.rb
rom-rails-0.8.0 spec/dummy/app/controllers/users_controller.rb
rom-rails-0.7.0 spec/dummy/app/controllers/users_controller.rb
rom-rails-0.6.0 spec/dummy/app/controllers/users_controller.rb
rom-rails-0.6.0.rc1 spec/dummy/app/controllers/users_controller.rb
rom-rails-0.6.0.beta1 spec/dummy/app/controllers/users_controller.rb
rom-rails-0.5.0 spec/dummy/app/controllers/users_controller.rb
rom-rails-0.5.0.rc1 spec/dummy/app/controllers/users_controller.rb
rom-rails-0.5.0.beta1 spec/dummy/app/controllers/users_controller.rb
rom-rails-0.4.0 spec/dummy/app/controllers/users_controller.rb
rom-rails-0.3.3 spec/dummy/app/controllers/users_controller.rb
rom-rails-0.3.2 spec/dummy/app/controllers/users_controller.rb
rom-rails-0.3.1 spec/dummy/app/controllers/users_controller.rb