I found a database_form extension plugin somewhere that seems to be
working, but hell if I remember where it came from.
This is my process function:
def process(request, response)
@request, @response = request, response
@form_name, @form_error = nil, nil
if request.post?
@form_data = request.parameters[:content].to_hash
# Remove certain fields from hash
form_data.delete("Submit")
form_data.delete("Ignore")
form_data.delete_if { |key, value| key.match(/_verify$/) }
@form_name = request.parameters[:form_name]
redirect_to = request.parameters[:redirect_to]
if save_form and redirect_to
response.redirect(redirect_to, "302")
else
super(request, response)
end
else
super(request, response)
end
end
Seems to work fine.
On Thu, Aug 21, 2008 at 2:29 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> It looks like the problem with the database_form extension is with the
> redirect. I don't know exactly how to fix it or even how to fully
> explain why it's not working. But, I did find what looks like a fix on
> the radiantcms-dev google group.
>
> This is where things are going wrong in the extension (lines 22-26) of
> the extension:
> ~~~~
> if save_form and redirect_to
> response.redirect(redirect_to)
> else
> super(request, response)
> end
> ~~~~
>
> This is the fix that Charlie Robbins suggested
> (link:
> http://groups.google.com/group/radiantcms-dev/browse_thread/thread/783c07a89beafcf5):
> ~~~~
> #Trim the leading / off the slug
> redirect_to = redirect_to.gsub(/^\//, '')
> @response.body = redirect_to
> @response.body = Page.find(:first, :conditions => ["slug = ?",
> redirect_to]).render
> ~~~~
>
> Now cannot really make heads or tails of this. Can anybody explain what
> is happening here? The author of the extension wrote in the ReadMe that
> the extension worked with Radiant 0.6.4. Could there be something in
> Radiant that changed to break this extension or was it not properly
> written to begin with? Not trying to step on any toes, but it seems like
> this extension would be more sought after and it would be nice to see it
> working properly.
>
> When I substitute the "fixed" code from Charlie, I get this error:
> You have a nil object when you didn't expect it!
> The error occurred while evaluating nil.render
>
> Any insight would be appreciated.
>
>
> Thanks,
>
> Nate
>
> _______________________________________________
> Radiant mailing list
> Post: [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant