Sha256: b3bbed428233c08e4b1e332831174aeed71cf765bba5125439504082d75714d0

Contents?: true

Size: 1.87 KB

Versions: 6

Compression:

Stored size: 1.87 KB

Contents

<% with_modules(modules) do -%>
class <%= class_name %> < Application
  # provides :xml, :yaml, :js

  # GET /<%= resource_path %>
  def index
    @<%= plural_model %> = <%= model_class_name %>.all
    display @<%= plural_model %>
  end

  # GET /<%= resource_path %>/:id
  def show
    @<%= singular_model %> = <%= model_class_name %>.find(params[:id])
    raise NotFound unless @<%= singular_model %>
    display @<%= singular_model %>
  end

  # GET /<%= resource_path %>/new
  def new
    only_provides :html
    @<%= singular_model %> = <%= model_class_name %>.new(params[:<%= singular_model %>])
    render
  end

  # POST /<%= resource_path %>
  def create
    @<%= singular_model %> = <%= model_class_name %>.new(params[:<%= singular_model %>])
    if @<%= singular_model %>.save
      redirect url(:<%= (modules.collect{|m| m.downcase} << singular_model).join("_") %>, @<%= singular_model %>)
    else
      render :new
    end
  end

  # GET /<%= resource_path %>/:id/edit
  def edit
    only_provides :html
    @<%= singular_model %> = <%= model_class_name %>.find(params[:id])
    raise NotFound unless @<%= singular_model %>
    render
  end

  # PUT /<%= resource_path %>/:id
  def update
    @<%= singular_model %> = <%= model_class_name %>.find(params[:id])
    raise NotFound unless @<%= singular_model %>
    if @<%= singular_model %>.update(params[:<%= singular_model %>])
      redirect url(:<%= (modules.collect{|m| m.downcase} << singular_model).join("_") %>, @<%= singular_model %>)
    else
      raise BadRequest
    end
  end

  # DELETE /<%= resource_path %>/:id
  def destroy
    @<%= singular_model %> = <%= model_class_name %>.find(params[:id])
    raise NotFound unless @<%= singular_model %>
    if @<%= singular_model %>.destroy
      redirect url(:<%= (modules.collect{|m| m.downcase} << singular_model).join("_") %>s)
    else
      raise BadRequest
    end
  end

end
<% end -%>

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
shingara-merb_mongomapper-0.1.2 lib/generators/templates/resource_controller/app/controllers/%file_name%.rb
shingara-merb_mongomapper-0.1.3 lib/generators/templates/resource_controller/app/controllers/%file_name%.rb
shingara-merb_mongomapper-0.1.4 lib/generators/templates/resource_controller/app/controllers/%file_name%.rb
shingara-merb_mongomapper-0.1.5 lib/generators/templates/resource_controller/app/controllers/%file_name%.rb
merb_mongoid-0.1.0 lib/generators/templates/resource_controller/app/controllers/%file_name%.rb
merb_mongomapper-0.1.7 lib/generators/templates/resource_controller/app/controllers/%file_name%.rb