Activating Website Functions

The features described here are optional parts of Rails Connector versions up to 6.9.1. If you want to continue to use these features in a more recent version of the Rails Connector, you can find the corresponding source code in a Git repository.

Comments on Web Pages

The Rails Connector supports commenting on web pages. For this, it includes a database model as well as a controller and a partial.

To be able to use the commenting functionality, it needs to be activated first. For this, please edit the config/initializers/rails_connector.rb file and remove the hash character from #:comments,:

RailsConnector::Configuration.enable(
…
:comments,
…
)

Then, use the following command to have the required database migration steps generated:

rails generate rails_connector:comments

Run the migration script to create the database tables required for the comments:

rake db:migrate

To have the comments and the form for submitting a new comment displayed on a web page, the supplied comments partial is available. Use it as follows:

<%= render :partial => 'cms/comments' %>

If you wish to extend the way in which comments are processed, you can do so by subclassing the supplied DefaultCommentsController:

class CommentsController < RailsConnector::DefaultCommentsController
# Your code
end

Providing RSS Feeds

The Rails Connector includes a controller for delivering RSS feeds. Prior to using it, the RSS feature needs to be activated. For doing this, edit the config/initializers/rails_connector.rb file and remove the comment character from # :rss,:

RailsConnector::Configuration.enable(
…
:rss,
…
)

As a default, the RSS feed is generated from the CMS files located in a specific folder. This folder object must be loaded via the config/initializers/rails_connector.rb file, e.g. by means of a NamedLink:

# RSS-Feed:
#
# Specify the CMS object to use as the parent folder of the RSS feed
RailsConnector::Configuration::Rss.root = NamedLink.get_object('news')

The RSS feed is generated via the DefaultRssController, using the app/views/rss/_item.rss.builder template. For generating the feed differently, you can modify this template, or write your own controller that uses a different template:

 class RssController < RailsConnector::DefaultRssController
   def podcast_feed
     @obj = NamedLink.get_object('podcast_en')
     headers['Content-Type'] = 'application/rss+xml'
     render :layout => false
   end
 end