[Radiant] Working through an Extension
Mohit Sindhwani
tech at onghu.com
Sat Aug 4 12:00:31 CDT 2007
Sean Cribbs wrote:
>
>> Basically, I have an after_save filter that gets called when you try
>> to save the page. All I need to figure out now is how to get the
>> page ID of the record that was just saved, and more importantly, the
>> parameters that were entered into the partial added to the new and
>> edit page.
>>
> You're on the right track. It's easiest if the model is associated
> with Page, then you can just push the new objects into the association
> collection and not worry about the page id. Otherwise, it's available
> via self.id inside that callback. Add an attr_accessor with some
> variable-name that you check in the after_save callback... it'll just
> be a hash with the attributes passed into the form, which you can pass
> on to your associated model.
>
Hi Sean,
With a little help from you and LiveHTTPHeaders (extension for Firefox)
and adding in attr_accessor :user_text and changing the form field name
to page[user_text], I'm now finally able to access the user text in my
after_save filter.
Now, to figure out what I want to do with the text that the user
entered. I could store that to the database by creating a new object.
I'll now also look into your directly pushing the new objects into the
association collection.
On the other hand, a Property field may be best handled as a drop down
list that the user can select from and creating a 'belongs_to'
association.
Just one more question if I may: what is the recommended practice for
adding columns to the Pages table? Should I do an add_column and create
a migration in my extension for it or should I just create a separate table?
Thanks again!
Cheers,
Mohit.
8/5/2007 | 12:54 AM.
More information about the Radiant
mailing list