Giter VIP home page Giter VIP logo

rails-template's Introduction

This includes scripts, templates and links to setup a Rails project.

Requirements

For newer Rails applications, the default JS assets manager is Webpack (through the Webpacker gem), so any modern Rails app requires Yarn as a dependency.

Usage

This project provides an rc file that you can use when creating new rails projects with some defaults. If you put the .railsrc file in your HOME directory, you can simply run the rails new command and it will use that file's content:

rails new projectname

If you want to put the rc file somewhere else and with another name, you can use the --rc=path option to target that file:

rails new projectname --rc=/some/path/to/myrailsrc

Notes

  • You can use any standard rails new command options (run rails new --help for details)
  • You can still override the options defined in the .railsrc file. If, for example, you want to use MySQL, you can still do rails new some_project --database=mysql that will override the default
  • The rc file can be ignored completely using the option --no-rc in case you want to ignore all the defaults for a given project (rails new some_project --no-rc)

.railsrc

The file includes default options that will be used when creating a new rails app. These options cannot be handled by a Rails Application Template, both the RC file and the template are needed. Each option goes in a new line.

What it Does

This file contains these lines:

--skip-bundle # don't run bundle, we want to modify the gemfile first
--skip-test # skip minitest gem setup, we are using rspec
--skip-turbolinks # don't add Turbolinks gem to the project
--database=postgresql # use postgres instead of sqlite
--skip-webpack-install # skip webpacker install, we want to run this in a particular order
-m https://raw.githubusercontent.com/ombulabs/rails-template/main/template.rb # use the template.rb file from this repo

Downloading the File

You can download the file manually or run this cURL command that will download the file into your HOME dir:

curl -o ~/.railsrc https://raw.githubusercontent.com/fastruby/rails-template/main/.railsrc

template.rb

This file is a Rails Application Template so we can configure how rails new behaves.

Usage

This file is referenced in the .railsrc file so it's used by default in that case. If you are not using the .railsrc file but still want to use the template, use this option when creating a new Rails project:

rails new PROJECT_NAME -m https://raw.githubusercontent.com/fastruby/rails-template/main/template.rb

What it Does

This file sets a few gems and tools, and configure them:

Each line (or group of lines) have a comment in that file explaining its purpose.

As a summary, it sets gems related to the styleguide, for tests, for linters and code quality and modifies config files.

Notes on Overcommit (git pre-commit hooks)

We don't want the linters to run for all the rails generated files (many of them won't pass the linter's checks but we don't want to modify internal files), so you can commit all the files before running the bin/setup script (overcommit won't be installed yet) or, if already run, you should disable it for the initial commit. To do so run:

OVERCOMMIT_DISABLE=1 git commit -a -m "Initial commit"

More Resources

TODO

  • Maybe move the script to setup the Mac environment to this repository? That script should take care of setting up rvm, ruby version, and could also copy the .railsrc file in the HOME dir
  • Add next_rails gem and config for current and master?
  • Maybe ask to select between ombulabs-styleguide, fastruby-styleguide or no styleguide

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fastruby/rails-template. 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.

When Submitting a Pull Request:

  • If your PR closes any open GitHub issues, please include Closes #XXXX in your comment

  • Please include a summary of the change and which issue is fixed or which feature is introduced.

  • If changes to the behavior are made, clearly describe what changes.

  • If changes to the UI are made, please include screenshots of the before and after.

Code of Conduct

Everyone interacting in the rails-template project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

rails-template's People

Contributors

abizzinotto avatar arielj avatar bronzdoc avatar cleicar avatar fbuys avatar neutrino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rails-template's Issues

[BUG] Use .env.local and .env.test

IMPORTANT: please make sure you ask yourself all intro questions and fill all sections of the template.

Before we start...:

  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository (for multi-repository projects)

Expected behavior:

Create a Rails app using this template.
Add ENV to the .env.sample file.
And be able to run the app with foreman or docker.

Actual behavior:

Running a newly created app (based on this template) does not run in docker or foreman.

Steps to reproduce:

  1. I create a rails app using this template.
  2. I add a few ENV entries into the .env.sample file.
  3. Then I run the setup script.
  4. Then I try to run the app in docker or with foreman.
  5. But the app does fails to run.

Context and environment:

From this issue: fastruby/dotenv_validator#46
And this PR: fastruby/dotenv_validator#51

The issue was that foreman and docker-compose would automatically parse any .env files present in the project and populate the environment variables before the Rails app could run, but with no treatment of comments and blank spaces. As a result, when dotenv parsed the file, since the variables would already be populated by docker, it would not change them and, because of this, dotenv_validator validated environment variables that included any blank spaces or comments present in the .env files.

This caused dotenv_validator to fail even for environment variables that should pass.

More details can be found in the changes to the README of dotenv_validator here. After this change we can now successfully run the app in docker and locally with foreman without dotenv_validator failing.

We want to make these changes:
Add this to .gitignore

.env.local
.env.test

Add to bin/setup

unless File.exist?(".env.local")
  cp ".env.sample", ".env.local"
  system! "ln -s .env.local .env.test"
end

I will abide by the [code of conduct] (CODE_OF_CONDUCT.md)

[BUG] : Missing default .env.sample

IMPORTANT: please make sure you ask yourself all intro questions and fill all sections of the template.

Before we start...:

  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository (for multi-repository projects)

Version, Branch, or Commit:

main @ ef2dd6b

Expected behavior:

I run bin/setup after creating a new rails app and expect it to run smoothly.

Actual behavior:

Please include a detailed description of the actual behavior of the application.
I run bin/setup and see an error related to the .env.sample file.

I think the bin/setup file needs to be updated to create an empty .env.sample file if it does not exist.

Steps to reproduce:

How do I achieve this behavior? Use the following format to provide a step-by-step guide:

  1. Step 1: Add the railsrc file to my system
  2. Step 2: Run rails new projectname
  3. Step 3: See the following error:

: No such file or directory @ rb_sysopen - .env.sample (Errno::ENOENT)

I will abide by the [code of conduct] (CODE_OF_CONDUCT.md)

[BUG] Rails already adds capybara and other gems

Version, Branch, or Commit:

Main branch

Expected behavior:

The template shouldn't add gems that are already in the Gemfile

Actual behavior:

The generation of the app fails because Capybara is defined twice (one by default and one added by the remplate)

Steps to reproduce:

Using rails 6.1.4.1

Run rails new PROJECT_NAME -m https://raw.githubusercontent.com/fastruby/rails-template/main/template.rb and you should see this error

[!] There was an error parsing `Gemfile`: You cannot specify the same gem twice with different version requirements.
You specified: capybara (>= 3.26) and capybara (>= 2.15). Bundler cannot continue.

 #  from ../PROJECT_NAME/Gemfile:64
 #  -------------------------------------------
 #  group :test do
 >    gem "capybara", ">= 2.15"
 #    gem "selenium-webdriver"
 #  -------------------------------------------

I will abide by the [code of conduct] (CODE_OF_CONDUCT.md)

[BUG] Stop spring at the end of the process

IMPORTANT: please make sure you ask yourself all intro questions and fill all sections of the template.

Before we start...:

  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository (for multi-repository projects)

Version, Branch, or Commit:
25026e8

Expected behavior:

It should terminate all the related processes.

Actual behavior:

We have lingering process from the newly generated Rails app.

Steps to reproduce:
1: Run rails new test-app --rc=./rails-template/.railsrc -m ./rails-template/template.rb from the parent directory of rails-template
2. ps aux | grep ruby lists few running processes

I will abide by the [code of conduct] (CODE_OF_CONDUCT.md)

[BUG] Template fails when running `next bundle install`

Version, Branch, or Commit:

Main branch

Expected behavior:

The generator should complete execution with the app with correct dual booting setup.

Actual behavior:

The generator fails when running next bundle install with this error:

         run    next bundle install from "."
The git source https://github.com/rails/rails.git is not yet checked out. Please run `bundle install` before trying to start your application

Steps to reproduce:

Create a new rails app using the template.

I will abide by the [code of conduct] (CODE_OF_CONDUCT.md)

[BUG] Reek missing `detectors` key

IMPORTANT: please make sure you ask yourself all intro questions and fill all sections of the template.

Before we start...:

  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository (for multi-repository projects)

Version, Branch, or Commit:

Inform what version, branch, commit of the project you are using.

Expected behavior:

  1. Create a new project with this template
  2. Run bin/setup
  3. Commit changes without any errors or problems

Actual behavior:

When I try to commit after running the bin/setup script I see an error message:
reek key 'Attribute:' is undefined.

According to the documentation over here:
https://github.com/troessner/reek/blob/master/docs/Reek-4-to-Reek-5-migration.md#reek-4-to-reek-5-migration

Reek 5 now requires a detectors key for standalone detectors.

So I think we just need to update the .reek.yml file.

Steps to reproduce:

How do I achieve this behavior? Use the following format to provide a step-by-step guide:

  1. Step 1: I use the template to create a new project
  2. Step 2: I run bin/setup
  3. Step: 3: I try to commit all changes
  4. Step 4: I see an error message reek key 'Attribute:' is undefined.

Context and environment:

Provide any relevant information about your setup (Customize the list accordingly based on what info is relevant to this project)

  1. Version of the software the issue is being opened for. Reek 5
  2. Ruby version: 3.01

I will abide by the [code of conduct] (CODE_OF_CONDUCT.md)

As an OmbuLabs / FastRuby.io developer, I'd like to be able to pick which style guide to use in my new Rails application

Why

As a developer
I want to be able to pick the style guide
So that I can save time implementing it in my project

Acceptance Criteria

Scenario: 
Given that we have three style guides (no style guide (Rails's default), OmbuLabs, or FastRuby.io)
When I start creating a new Rails project
Then I want to be able to pick the style guide for my project

Notes:

It would be great if there is a little dialogue that is presented to the user or an option to pick the style guide.

For example:

rails new foo
> Which style guide do you want to use? (rails/fastruby/ombulabs -- default: ombulabs)
> fastruby
> Cool, using fastruby style guide for project foo.

Or:

rails new foo --styleguide=fastruby
> Cool, using fastruby style guide for project foo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.