Hey,
I am still pretty new to Rails, so be gentle.
I want to build a component that lists items from the DB for a CMS we are
building. Listing items is so common, I''d rather follow DRY and build a
single component I can use all over.
I''m having a bit of trouble getting things in the right place.
This component needs to be able to display items from many different models,
the idea being that I pass in that information when I use it instead of in
the component itself.
I have the component files in the right place under components. Here is the
applicable method from the component controller:
def item_list
@item_pages, @items = paginate @item_label, :per_page => 20
render :layout => false
end
The view that embeds the component looks like this:
<%= render_component :controller => "item_list/item_list",
:action =>
"item_list", :params => {"page" => @params[:page],
"model" => Artist,
"item_label" => :artist, "edit_label" =>
"Bands"} %>
The problem is that it seems as if @item_label is null when it gets to the
component controller. The actual exception is this:
undefined method `count'' for Object:Class
But if you look at the object, it is nil.
My guess is that I''m probably going about this all wrong. If someone
could
give me a few pointers or even some sample code somewhere, it would be much
appreciated.
Cheers,
Hunter