class Object

Constants

LANGUAGES

Public Instance Methods

create() click to toggle source

POST /<%= controller_name %>.json

# File lib/generators/openehr/controller/templates/controller.rb, line 26
def create
  @<%= model_name %> = <%= model_class_name %>.new(<%= model_name %>_params)

  respond_to do |format|
    if @<%= model_name %>.save
      format.html { redirect_to @<%= controller_name %>, notice: '<%= archetype_name %> was successfully created.' }
      format.json { render action: 'show', status: :created, location: @<%= controller_name %> }
    else
      format.html { render action: 'new' }
      format.json { render json: @<%= controller_name %>, status: :unprocessable_entity }
    end
  end
end
index() click to toggle source

GET /<%= controller_class_name %>.json

# File lib/generators/openehr/controller/templates/controller.rb, line 6
def index
  @<%= model_name %> = <%= model_class_name %>.all
end

# GET /<%= controller_name %>/1
# GET /<%= controller_name %>/1.json
def show
end

# GET /<%= controller_name %>/new
def new
  @<%= model_name %> = <%= model_class_name %>.new
end

# GET /<%= controller_name %>/1/edit
def edit
end

# POST /<%= controller_name %>
# POST /<%= controller_name %>.json
def create
  @<%= model_name %> = <%= model_class_name %>.new(<%= model_name %>_params)

  respond_to do |format|
    if @<%= model_name %>.save
      format.html { redirect_to @<%= controller_name %>, notice: '<%= archetype_name %> was successfully created.' }
      format.json { render action: 'show', status: :created, location: @<%= controller_name %> }
    else
      format.html { render action: 'new' }
      format.json { render json: @<%= controller_name %>, status: :unprocessable_entity }
    end
  end
end

# PATCH/PUT /<%= controller_name %>/1
# PATCH/PUT /<%= controller_name %>/1.json
def update
  respond_to do |format|
    if @<%= model_name %>.update(<%= model_name %>_params)
      format.html { redirect_to @<%= controller_name %>, notice: '<%= archetype_name %> updated.
update() click to toggle source

PATCH/PUT /<%= controller_name %>/1 PATCH/PUT /<%= controller_name %>/1.json

# File lib/generators/openehr/controller/templates/controller.rb, line 42
def update
  respond_to do |format|
    if @<%= model_name %>.update(<%= model_name %>_params)
      format.html { redirect_to @<%= controller_name %>, notice: '<%= archetype_name %> updated.' }
      format.json { head :no_content }
    else
      format.html { render action: 'edit