How to create a form page in Refinery CMS app

refinerycms logo3
Social sharing

Refinerycms

Refinery is a powerful CMS based on Rails framework. It gives a fully generated site with admin control features. However, we can extend it to create our own customized forms like Job Inquiry, Contact Us etc… by following this tutorial. Here is the environment we have used on this tutorial.Ruby 1.9.3, Rails 3.2.8 & RefineryCMS 2.0.8

Step#1

Cd to refinerycms application

Execute the following command to get all the options & usages to create a form engine in refinery CMS

rails g refinery:form

Step#2

Execute the following command to create a form. Let’s create a Job Inquiry form

rails generate refinery:form job_inquiry name:string message:text job_type:radio brochure:checkbox qualification:select

Step#3

Run the following commands

bundle install
 
rails generate refinery:job_inquiries
 
rake db:migrate<code></code>
 
<code>rake db:seed<code>

ss

This will create a “job inquiry” engine in the “vendor/extensions” folder

Step#4
Add the “job type” and “qualification” data in the “/vendor/extensions/job_inquiries/app/models/refinery/job_inquiries/job_inquiry.rb” model. You can also add other fields as per your requirement.

module Refinery
module JobInquiries
class JobInquiry < Refinery::Core::BaseModel       self.table_name = 'refinery_job_inquiries'       attr_accessible :name, :message, :job_type, :brochure, :qualification, :position       acts_as_indexed :fields => [:name, :message]
# Add some validation here if you want to validate the user's input
# We have validated the first string field for you.
validates :name, :presence => true
JOB_TYPES = ["Freelance", "Fulltime", “Contract”]
QUALIFICATIONS = ["MCA", "MTECH", "BTECH"]
end
end
end

Step#5

Restart the rails server to get the effect

That’s it! We will have a fully functional Job Inquiry form attached in our refinery application. This will also add the following functionalities automatically.

  • Mail send feature to Admin after submitting the job inquiry form
  • Auto email respond functionality to the user after submitting the form
  • Adds Job Inquiry menu in the Admin side to manage auto email respond message, mail id change to get job inquiry
  • Adds an Inbox in the Job Inquiry Menu for Admin to manage all the forms submitted through the Job Inquiry form

SEE ALSO: Creation of a new Rails App using Refinery CMS

If you have any other tips or rules that you follow, let us know in the comments below.

Your recently viewed posts:

Jayadev Das - Post Author

Do what you do best in – that’s what I’ve always believed in and that’s what I preach. Over the past 25+ years (yup that’s my expertise ‘n’ experience in the Information Technology domain), I’ve been consulting to small, medium and large companies ‘About Web Technologies, Mobile Future as well as on the good-and-bad of tech. Blogger, International Business Advisor, Web Technology Expert, Sales Guru, Startup Mentor, Insurance Sales Portal Expert & a Tennis Player. And top of all – a complete family man!

    Contact Us

    We’d love to help & work with you




    When do you want to start ?


    Enter your email address to stay up to date with the latest news.
    Holler Box

    Orange Exit pop up

    Subscribe for the latest
    trends in web and
    mobile app development
    Holler Box

    Exit pop up

    Sad to see you leaving early...

    From "Aha" to "Oh shit" we are sharing everything on our journey.
    Enter your email address to stay up to date with the latest news.
    Holler Box