Rostra allows you to quickly add a question and answer forum to your application. Requires Rails 3.1 and Ruby 1.9.2.
NOTE: Rostra is not production ready.
Installation
Include the gem to your Gemfile
:
gem 'rostra'
Mount the engine in config/routes.rb
:
mount Rostra::Engine => "/rostra" # or whatever path you like
Install and run the necessary migrations:
rake rostra:install:migrations
rake db:migrate
Run the generator to create config/initializers/rostra.rb
and app/helpers/application_helper.rb
:
rails generate rostra:install
Call rostra
in your user model:
class User < ActiveRecord::Base
rostra
end
Basic configuration
There’s some stuff you’ll almost definitely want to do in order to get Rostra working correctly for your app. First, set the default_url_options
for your app. In each of your config/environment
files you should have something like:
config.action_mailer. = { :host => 'test.com' } # test.rb
config.action_mailer. = { :host => 'localhost:3000' } # development.rb
config.action_mailer. = { :host => 'your_domain.com' } # production.rb
Also, be sure to read through config/initializers/rostra.rb
and override configuration options to suit your app. At the very least, you’ll want to change:
config.deliver_emails_from = '[email protected]'
Finally, have a look at app/helpers/rostra/application_helper.rb
, you may need to add/override helper methods.
Overriding models
Rostra provides a DSL for adding application specific logic to Rostra::Question
and Rostra:Answer
:
class User < ActiveRecord::Base
rostra do
questions do
# Code inside this block will be evaluated in the context of `Rostra::Question`.
# So an instance method might look like:
#
def active?
# call this like @question.active?
end
end
answers do
# Code inside this block will be evaluated in the context of `Rostra::Answer`
# So a class method might look like:
#
def self.recently_up_voted
# call this like Rostra::Answer.recently_up_voted
end
end
end
end
Overriding Controllers
Added instructions for overriding controllers here (including generators!)
Setting permissions
Under the hood, Rostra uses CanCan
to set permissions. By default anyone can read rostra content - even if they are not logged in. A user can contribute content (i.e. ask questions, give answers, and leave comments) as long as they’ve logged in.
If you need to change these defaults, override can_participate_in_rostra?
in your user model. CanCan
will use this method to determine who can participate. If you need to specify even more complicated permissions, override app/models/rostra/ability.rb
and go wild.
Contributing to Rostra
Fork the project, make your changes, and submit a pull request. Please ensure the tests pass:
rspec spec # runs the specs
cucumber features # runs the cukes
Contributors: robertwalsh0, bcody
License
This project uses MIT-LICENSE.