Generates a Rails app with the Thredded forums engine installed.
See below for more information on the generated app.
Example screenshots of the generated app:
- Git.
- A supported database: PostgreSQL (recommended), MySQL v5.7+, or SQLite.
- Ruby 2.3+.
Install the gem and create your app:
gem install thredded_create_app
thredded_create_app myapp
By default, PostgreSQL will be used as the database.
Alternatively, you can pass --database sqlite3
for SQLite,
or --datase mysql2
for MySQL.
Run thredded_create_app --help
for more information about the available
options.
If you're using RVM, you probably want to create a gemset before creating your app:
RUBY_VERSION=2.3.1 APP=myapp
rvm use --create "${RUBY_VERSION}@${APP}"
gem install thredded_create_app
thredded_create_app "$APP"
Then, generate the .ruby-version
and .ruby-gemset
files so that the gemset
is used automatically whenever you cd
into the project directory:
cd "$APP"
rvm use --ruby-version "${RUBY_VERSION}@${APP}"
printf '.ruby-version\n.ruby-gemset\n' >> .git/info/exclude
The app generator will do the steps below for you.
First, the rubygems package is updated and the latest versions of Rails and Bundler are installed.
Then, a Rails app is generated for use with the selected database.
Then, a git repository is initialized in the app directory. From here onwards, the app generator will commit the changes at each step.
RSpec is used as the testing framework, and some basic acceptance tests using capybara are added.
Devise is used as the authentication framework. Its default views are
customized to add a user name field (display_name
) to the registration form.
The simple_form gem is used for the customized Devise views by default.
A basic responsive app layout with top bar navigation is added. A user profile page that displays some basic information about the user and their recent forum posts is also added.
The app comes with basic styles (~10KiB gzipped, including Thredded styles) that are written using Sass.
The app's JavaScript code is loaded asynchronously in production mode via the
async
attribute on the script tag. In development, the individual script
files are not concatenated. With async
they would load out-of-order, so
defer
is used instead.
NB: While loading scripts via async
provides the best possible speed,
a lot of JavaScript libraries do not support it.
If you plan on adding JavaScript code, you might want to
remove the async
attribute from the javascript_include_tag
in
app/views/layouts/application.html.erb
.
A Dockerfile and docker-compose.yml is generated for development. This is so that other engineers can spin up a development environment with a single command.
A production configuration file for the puma Ruby web server is created.
A Procfile
process description file is also created. This file can be used by
the Heroku hosting platform or the foreman app runner.
Lastly, the $APP
database user is created and given rights to the app's
development and test databases. Then, the database is created, the migrations
are run, and the database is seeded with an admin user and a messageboard.
Finally, the tests are run, and the development web server is started at http://localhost:3000.
To learn about customizing the forums, see the Thredded Readme.
To learn about customizing the authentication system, e.g. to require email confirmation or to add an OAuth login, see the Devise Readme.
To change the homepage, edit the view file at app/views/home/show.html.erb
.
To change the app's styles, see the files in app/assets/stylesheets
.
The app is generated with a randomly selected primary theme color that you may
want to change. You can find it in app/assets/stylesheets/_variables.scss
.
You can contact the Thredded team via the Thredded chat room. Once you've deployed your app, please let us know that you are using Thredded by tweeting @thredded!
The instructions below are for developing and contributing to the Thredded app generator itself, not for using it.
After checking out the repo, run bin/setup
to install dependencies.
Then, run rake spec
to run the tests.
You can also run bin/console
for an interactive prompt that will allow you
to experiment.
To generate an app with thredded_create_app
at tmp/myapp
, run:
bundle exec bin/create-tmp-myapp
This command will clean up the previously generated app before creating a new one.
To install this gem onto your local machine, run bundle exec rake install
.
To release a new version, update the version number in version.rb
, and then
run bundle exec rake release
, which will create a git tag for the version,
push git commits and tags, and push the .gem
file to
rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/thredded/thredded_create_app. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.