Refinery Inquiry Forms in Different Pages

175 views
Skip to first unread message

Ali Aljunied

unread,
Jan 8, 2015, 2:49:30 PM1/8/15
to refine...@googlegroups.com
Hey,

I'm new to RoR and Refinery. I am trying to recreate a one-page static website of mine to use Refinery so that I can easily post up my "Recent Works" and maintain a blog in a more easy fashion.

I've got refinerycms-inquiries (3.0.0) installed with refinerycms (3.0.0) running on Ruby (2.2.0) and Rails (4.1.9) 

I've been trying to add a form to the pages/home.html.erb which is where my static site resides in:

...


<div class='inquiries'>
     
<%= render '/refinery/inquiries/inquiries/form', inquiry: @inquiry %>
</div>


...



Whenever I load the page, I receive this error:


First argument in form cannot contain nil or be empty

Extracted source (around line #1):


1
2
3
4 
<%= form_for [refinery, :inquiries, inquiry] do |f| %>
<%= render :partial => "/refinery/admin/error_messages",
:locals => {
:object => inquiry,

Can anyone help me out? Thanks!

Philip Arndt

unread,
Jan 8, 2015, 2:55:14 PM1/8/15
to refine...@googlegroups.com
Do you have Refinery mounted in config/routes.rb? If so, can you paste the line here?

Ali Aljunied

unread,
Jan 8, 2015, 3:19:18 PM1/8/15
to refine...@googlegroups.com
Hey parndt,

Thanks for the quick reply.

This is my config/routes.rb

Rails.application.routes.draw do
   mount
Refinery::Core::Engine, at: '/'
end

Philip Arndt

unread,
Jan 8, 2015, 3:22:25 PM1/8/15
to refine...@googlegroups.com
That seems fine, it just seems like it's not understanding the refinery routing helper for some reason.  Do you have steps that we can use to reproduce this in a basic rails application, perchance?

ali aljunied

unread,
Jan 8, 2015, 3:32:44 PM1/8/15
to refine...@googlegroups.com

Hmm.. Unfortunately no. Ill briefly describe what I have been doing though.

I spent quite some time trying to just install and get refinerycms working on my machine (Mac Yosemite) only to find out I was using the wrong versions.

In that process, I uninstalled rbenv, installed rvm, then switched back to rbenv.

After all that, I managed to get refinerycms working, and went through a lot of 'rails g' and 'rails d' to get the form to work using a model and then decided not to use a model.

I messed around with the routing, adding lines for the form_tag that does not use a model, only to find I should have use the 'prepend' method.

I finally chanced upon the previous post of the guy wanting to use the inquiry form as a partial, and followed his code which taught me that I should look into the source code when I can't find any tutorials or guides online.

Heh, yeah it's been a long two days for me.

So that's like my process. Do you suggest I redo everything from scratch? I might have messed up something along way.

On 9 Jan 2015 04:22, "Philip Arndt" <par...@gmail.com> wrote:
That seems fine, it just seems like it's not understanding the refinery routing helper for some reason.  Do you have steps that we can use to reproduce this in a basic rails application, perchance?

--
You received this message because you are subscribed to the "Refinery CMS" Google Group.
To post to this group, send email to refine...@googlegroups.com
 
http://www.refinerycms.com
---
You received this message because you are subscribed to the Google Groups "Refinery CMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to refinery-cms...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/refinery-cms/EAEE4B1403E44414AF926356C91F2CEB%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Philip Arndt

unread,
Jan 8, 2015, 3:51:33 PM1/8/15
to refine...@googlegroups.com
I'd recommend starting a new application side by side and introducing things from the current application until they either work and didn't before or fail and didn't before.  Then you could compare the differences.

rails _4.1.9_ new myappname -m http://refinerycms.com/t/edge

You can also pass -d with mysql or postgresql to avoid sqlite3.

ali aljunied

unread,
Jan 8, 2015, 3:53:24 PM1/8/15
to refine...@googlegroups.com

Thanks Philip!

I'll do that!

--
You received this message because you are subscribed to the "Refinery CMS" Google Group.
To post to this group, send email to refine...@googlegroups.com
 
http://www.refinerycms.com
---
You received this message because you are subscribed to the Google Groups "Refinery CMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to refinery-cms...@googlegroups.com.

Matthias Frick

unread,
Jan 9, 2015, 6:00:28 AM1/9/15
to refine...@googlegroups.com
Could it be that simple "@inquiry" is nil?

You just render the form partial in your page - did you instantiate the @inquiry variable somewhere?

For example in your controller..

    @inquiry = Inquiry.new

?

Ali Aljunied

unread,
Jan 11, 2015, 7:20:22 AM1/11/15
to refine...@googlegroups.com
Hey Matthew!

Thanks for the reply.

I tried this by extending the Pages Controller (I only have one page, the Home page).

So in the pages_controller_decorator.rb:

Refinery::PagesController.class_eval do

  before_filter
:newForm

 
def newForm()
   
@inquiry = Inquiry.new
 
end

end

and in my pages/home.html.erb:

...

<div id="contact-form">
         
<% content_for :body do %>
             
<%= raw @page.content_for(Refinery::Pages.default_parts.first.to_sym) if Refinery::Pages.default_parts.any? %>


             
<div class='inquiries'>
               
<%= render '/refinery/inquiries/inquiries/form', inquiry: @inquiry %>
             
</div>

         
<%end%>

...

The error:

uninitialized constant Inquiry


on in the pages_controller_decorator.rb:
@inquiry = Inquiry.new

So I am not sure if I am supposed to add a line in one of the config files of the project to include the refinery_inquriy to like "link" it to the main core app.

Please advice. Thanks!

-ali

Philip Arndt

unread,
Jan 11, 2015, 4:41:56 PM1/11/15
to refine...@googlegroups.com
Try this:

    Refinery::PagesController.class_eval do

      before_filter :build_inquiry

      def build_inquiry
        @inquiry = Refinery::Inquiries::Inquiry.new
      end

    end


The reason is that the Inquiry object is namespaced under `Refinery::Inquiries` which is the namespace used in the refinerycms-inquiries extension.  This namespacing, while seemingly over the top, helps to isolate each extension from other similar extensions and ensures that nothing clashes.

Matthias Frick

unread,
Jan 12, 2015, 7:11:20 AM1/12/15
to refine...@googlegroups.com
Ahh I am sorry I forgot the namespace :-).. but @parndt already corrected my code.
Reply all
Reply to author
Forward
0 new messages