[Radiant] Does database_form extension work with Rails 2?

3 views
Skip to first unread message

pixe...@gmail.com

unread,
Aug 21, 2008, 10:38:28 AM8/21/08
to rad...@radiantcms.org
I guess the title says it all. I have installed the extension properly
with no errors and I can see the admin page for retrieving results from
it, but I don't see any of the tags available and when I use it on a
page I get a "undefined tag `database’" error on the page. Has anybody
used this extension on a site with Rails 2 (2.0.2) and Radiant 0.6.7?


The extension is here:
http://github.com/zapnap/database_form/tree/master

The page I am trying to use it on:
http://texashope.andadv.com/prayer


Thanks,
Nate

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

Josh Schairbaum

unread,
Aug 21, 2008, 10:59:44 AM8/21/08
to rad...@radiantcms.org
Make sure that you define your page as a type of 'database' or
whatever. The tag is only available on pages that are of that type.

pixe...@gmail.com

unread,
Aug 21, 2008, 11:08:47 AM8/21/08
to rad...@radiantcms.org
On Thu, 2008-08-21 at 10:59 -0400, Josh Schairbaum wrote:
> Make sure that you define your page as a type of 'database' or
> whatever. The tag is only available on pages that are of that type.

Man, I feel like suck a goon. That did the trick.


~Nate

Josh Schairbaum

unread,
Aug 21, 2008, 11:20:27 AM8/21/08
to rad...@radiantcms.org
Don't feel bad... there's a reason why that would come to the front of
my mind. :)

pixe...@gmail.com

unread,
Aug 21, 2008, 4:20:37 PM8/21/08
to rad...@radiantcms.org
On Thu, 2008-08-21 at 11:20 -0400, Josh Schairbaum wrote:
> Don't feel bad... there's a reason why that would come to the front of
> my mind. :)

Have you ever had to deal with the "wrong number of arguments (1 for 2)"
error? I finally got the form built and pages all set up, tried out the
form and BANG, I have that stupid error. It's why gave up on the
extension the last time I tried to use it.

If you have ever seen this and know how to fix it, please let me know.

Thanks,

pixe...@gmail.com

unread,
Aug 21, 2008, 5:29:15 PM8/21/08
to rad...@radiantcms.org
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,

pixe...@gmail.com

unread,
Aug 21, 2008, 11:26:37 PM8/21/08
to rad...@radiantcms.org
Just so that it's on the record for the next time that somebody has a
similar problem. I found the answer to the "wrong number of arguments (1
for 2)" happening on the database_form extension. The redirect needs to
have the status code "302" added to it.

This:
...


if save_form and redirect_to
response.redirect(redirect_to)
else
super(request, response)
end

...

Becomes this:
...
if save_form and redirect_to
response.redirect(redirect_to, "302")
else
super(request, response)
end
...

In tracking down this problem I found that Joel Williams had forked the
database_form extension and he had solved the problem I was running
into. As his fork includes some other added functionality, I have
switched to it instead of the original extension from Zapnap (Nick
Plante).

Back to your regularly scheduled program...


~Nate

Joe Van Dyk

unread,
Aug 22, 2008, 3:06:16 PM8/22/08
to rad...@radiantcms.org
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.

Joe Van Dyk

unread,
Aug 22, 2008, 3:08:29 PM8/22/08
to rad...@radiantcms.org

Joe Van Dyk

unread,
Aug 22, 2008, 3:09:50 PM8/22/08
to rad...@radiantcms.org
Doh, I answered you with this. :)

zapnap should merge that fix into his plugin, or the radiant extension
page should link to the working plugin.


Joe

Joe Van Dyk

unread,
Aug 22, 2008, 3:37:17 PM8/22/08
to rad...@radiantcms.org
Yup, there's two other very recent threads about this issue.

Use this plugin instead: http://github.com/joelw/database_form/commits/master

And someone should update the radiant site to point at that plugin
instead, zapnap's is broken on recent radiant/rails.

Joe

Reply all
Reply to author
Forward
0 new messages