Sha256: dc82fdde66c6024692b7435246321b04f6c98d65df4892ef12012258ef291394

Contents?: true

Size: 1.81 KB

Versions: 3

Compression:

Stored size: 1.81 KB

Contents

class <%=parent_plural_class_name%>Controller < ApplicationController
	
	filter_resource_access
	
	layout 'cms'
	
  def index
    @<%=parent_plural_name%> = <%=parent_class_name%>.page(params[:search], params[:page])
  end
  
  def show
    @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id], :include => :<%=child_plural_name%>)
		@new_<%=child_singular_name%> =	<%=child_class_name%>.new(:<%=parent_singular_name%>_id => @<%=parent_singular_name%>.id)
  end
  
  def new
    @<%=parent_singular_name%> = <%=parent_class_name%>.new
  end
  
  def create
    @<%=parent_singular_name%> = <%=parent_class_name%>.new(params[:<%=parent_singular_name%>])
    if @<%=parent_singular_name%>.save
      flash[:notice] = "Successfully created <%=parent_singular_name%>."
      redirect_to @<%=parent_singular_name%>
    else
      render :action => 'new'
    end
  end
  
  def edit
    @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id])
  end
  
  def update
    @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id])
    if @<%=parent_singular_name%>.update_attributes(params[:<%=parent_singular_name%>])
      flash[:notice] = "Successfully updated <%=parent_singular_name%>."
      redirect_to view_<%=parent_singular_name%>_path(@<%=parent_singular_name%>.filename)
    else
      render :action => 'edit'
    end
  end
  
  def destroy
    @<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id])
    @<%=parent_singular_name%>.destroy
    flash[:notice] = "Successfully destroyed <%=parent_singular_name%>."
    redirect_to <%=parent_plural_name%>_url
  end

	def manage
		@<%=parent_singular_name%> = <%=parent_class_name%>.find(params[:id], :include => :<%=child_plural_name%>)
		@<%=child_plural_name%> = @<%=parent_singular_name%>.<%=child_plural_name%>
		render :layout => false
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dust-generators-0.2.6 lib/generators/dust/albums/templates/app/controllers/albums_controller.rb
dust-generators-0.2.5 lib/generators/dust/albums/templates/app/controllers/albums_controller.rb
dust-generators-0.2.4 lib/generators/dust/albums/templates/app/controllers/albums_controller.rb