Christian,

Admin::ResourceController gives you CRUD methods so you don't have to define 
them yourself. Methods like  :index, :edit, :update, :new, :create, :delete  
are built in.

So on a plugin I am working on I only define the show method (controller for a 
podcast's Shows) to get a single 'Show' in my podcast...

class Admin::ShowsController < Admin::ResourceController
  model_class Show
  
  before_filter :find_model, :only => [ :show ]
  
  def show
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @show }
    end
  end
  
  private
    def find_model
      @show = Show.find(params[:id]) if params[:id]
    end
  
end

Regards,

-Bill
pixelhandler

On Feb 6, 2010, at 10:00 AM, radiant-requ...@radiantcms.org wrote:

> Message: 1
> Date: Sat, 6 Feb 2010 17:18:34 +0100
> From: Christian Aust <christian.a...@software-consultant.net>
> Subject: [Radiant] What does Admin::ResourceController do?
> To: radiant@radiantcms.org
> Message-ID:
>       <3b13c44e-4d65-48f1-a610-c457823a0...@software-consultant.net>
> Content-Type: text/plain; charset=us-ascii
> 
> Hi all,
> 
> I'm writing an extension to Radiant that defines new database entities. The 
> docs suggest to let my controller inherit from Admin::ResourceController, to 
> "get a lot of functionality for free". What is that functionality, 
> specifically?
> 
> In particular, I've been confused by that :singular and :plural stuff in 
> there, what's that? When do I need that?
> 
> What's going on with the @template_name and @controller_name variables, what 
> do I need them for?
> 
> As I've mentioned before, Radiant itself is pretty neat, but documentation on 
> these parts of its public API isn't only lacking but non-existant. That makes 
> it harder to understand errors like this: My entity is called "City", I've 
> copied all relevant code from Radiants Page view and controller. The edit 
> haml throws this error:
> 
> undefined method `cities' for #<Radiant::AdminUI:0x102036be8>
> 
> Extracted source (around line #1):
> 
> 1: - render_region :main do |main|
> 2:   - main.edit_header do
> 3:     %h1 Edit City
> 4:   - main.edit_form do
> 
> /opt/local/lib/ruby/gems/1.8/gems/radiant-0.8.1/app/helpers/admin/regions_helper.rb:25:in
>  `send'
> /opt/local/lib/ruby/gems/1.8/gems/radiant-0.8.1/app/helpers/admin/regions_helper.rb:25:in
>  `lazy_initialize_region_set'
> /opt/local/lib/ruby/gems/1.8/gems/radiant-0.8.1/app/helpers/admin/regions_helper.rb:3:in
>  `render_region'
> /Users/christian/mueller/vendor/extensions/mueller/app/views/admin/cities/edit.html.haml:1:in
>  
> `_run_haml_vendor47extensions47mueller47app47views47admin47cities47edit46html46haml'
> 
> It feels like I've got something wrong while copying code, but I can't easily 
> tell what. Can you? Kind regards,
> 
> Christian
> 
> ------------------------------

_______________________________________________
Radiant mailing list
Post: Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
List Site: http://lists.radiantcms.org/mailman/listinfo/radiant
Radiant: http://radiantcms.org
Extensions: http://ext.radiantcms.org

Reply via email to