Sha256: fbeb728fba4dea1bc06315a2792e6c57ec9002795f0cab2971ec1b9087ad369b

Contents?: true

Size: 806 Bytes

Versions: 8

Compression:

Stored size: 806 Bytes

Contents

class <%= plural_class_name %>Controller < Gluttonberg::Public::BaseController

  def index
    @<%= plural_name %> = <%= class_name %>.published<% if draggable? %>.order('position asc') <%end%>
    respond_to do |format|
      format.html
    end
  end

  def show
    @custom_model_object = @<%= singular_name %> = <%= class_name %>.published.where(:slug => params[:id]).first
    if @<%= singular_name %>.blank?
      @<%= singular_name %> = <%= class_name %>.published.where(:previous_slug => params[:id]).first
      unless @<%= singular_name %>.blank?
        redirect_to <%= singular_name %>_path(@<%= singular_name %>.slug) , :status => 301
      end
    end
    raise ActiveRecord::RecordNotFound.new if @<%= singular_name %>.blank?
    respond_to do |format|
       format.html
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gluttonberg-core-3.0.2 lib/generators/gluttonberg/resource/templates/public_controller.rb
gluttonberg-core-3.0.1 lib/generators/gluttonberg/resource/templates/public_controller.rb
gluttonberg-core-3.0.0 lib/generators/gluttonberg/resource/templates/public_controller.rb
gluttonberg-core-2.6.4 lib/generators/gluttonberg/resource/templates/public_controller.rb
gluttonberg-core-2.6.3 lib/generators/gluttonberg/resource/templates/public_controller.rb
gluttonberg-core-2.6.2 lib/generators/gluttonberg/resource/templates/public_controller.rb
gluttonberg-core-2.6.1 lib/generators/gluttonberg/resource/templates/public_controller.rb
gluttonberg-core-2.6.0 lib/generators/gluttonberg/resource/templates/public_controller.rb