views:

14

answers:

1

I currently have a generic list that is generated by ActiveScaffold. At the end of each row in the list, ActiveScaffold adds the standard CRUD links - Show, Edit, Delete - for each record.

I do not wish to use ActiveScaffold for these actions (long story) and have created my own controllers to handle this. I am trying to override these links to point to my own controllers but I can't quite work out how to pass through the ID of the record.

For example, say I want the new link for Show to be /foo/show/[id] - I have this in my ActiveScaffold configuration:

config.show.link.action = "show"
config.show.link.parameters = {:controller => "foo", :id => ???}

I don't know what to pass through in the id parameter. I have tried using things like :foo_id, or foo_id, but the controller doesn't know what they are. When I use :foo_id, for example, I just get the String - /foo/show/foo_id.

My controller is below, but there isn't much to it.

class MessagesController < ApplicationController

    active_scaffold :messages do |config|

        config.columns = [:eff_date, :exp_date, :type, :message]

        config.show.link.action = "show"
        config.show.link.parameters = {:controller => "show_messages", :id => ??}

    end

end

I'd like to keep using ActiveScaffold for the list screen because I don't really want to have to roll my own version of the listing. I found a guy asking the same question in googlegroups but there was no response.

http://www.mail-archive.com/[email protected]/msg00798.html

Edit: I should add that not specifying the :id parameter does in fact put the default ActiveRecord ID in the field but it is not quite the one I want - again, long story ... :(

A: 

Alright well this probably isn't the best solution but it's the most obvious.

In my "Edit:" I added in a pretty important detail that I originally omitted. ActiveScaffold was automatically setting the ID in the URL as one from the current record however my custom controllers actually required a different ID (a foreign key on the record, actually).

The solution - now obvious - was to just change my custom controller to use the default ID it passed through and change the ActiveRecord query to use this ID... d'oh.

Ben J