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.