Sha256: 58540b0d968f52752094a19d09f79e03c8a7e1ad7731eec43dc3015d2769e551

Contents?: true

Size: 1.08 KB

Versions: 61

Compression:

Stored size: 1.08 KB

Contents

class <%= scope_class %>::<%= controller_class_name %>Controller < <%= scope_class %>::BaseController
  respond_to :html, :js
  
  def index
    @search = <%= resource_class_name %>.search(params[:search])
    @<%= collection_name %> = @search.page(params[:page] || 1)
  end

  def new
    <%- if content? -%>
    @<%= resource_name %> = <%= resource_class_name %>.new(:author_id => current_user._id)
    <%- else -%>
    @<%= resource_name %> = <%= resource_class_name %>.new  
    <%- end -%>
  end
  
  def edit
  end
  
  def create
      @<%= resource_name %> = <%= resource_class_name %>.new(params[:<%= resource_name %>])
      
      if @<%= resource_name %>.respond_to?(:author)
        @<%= resource_name %>.author ||= current_user
      end
      
      @<%= resource_name %>.save
      respond_with(@<%= resource_name %>)
  end

  def update
    @<%= resource_name %>.attributes = params[:<%= resource_name %>]
    @<%= resource_name %>.save
    respond_with(@<%= resource_name %>)
  end

  def destroy
    @<%= resource_name %>.destroy
    respond_with(@<%= resource_name %>)
  end
end


Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
fullstack-admin-0.1.41 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.40 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.39 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.38 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.37 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.36 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.35 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.34 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.33 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.32 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.30 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.29 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.28 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.27 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.26 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.25 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.24 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.23 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.20 lib/generators/fullstack/admin/templates/scaffold/controller.rb
fullstack-admin-0.1.19 lib/generators/fullstack/admin/templates/scaffold/controller.rb