https://github.com/bodacious/orthodox
Rails generators for my own projects
https://github.com/bodacious/orthodox
Last synced: about 1 month ago
JSON representation
Rails generators for my own projects
- Host: GitHub
- URL: https://github.com/bodacious/orthodox
- Owner: Bodacious
- License: mit
- Created: 2017-07-07T12:28:43.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-09T01:35:00.000Z (over 3 years ago)
- Last Synced: 2024-11-24T19:44:17.457Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 246 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Orthodox
Better Rails generators for modern apps
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'orthodox', github: "bodacious/orthodox"
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install orthodox
## Usage
### A Coffeescript file:
rails g coffeescript users
Creates
window.users = do ->
init = ->
return { init }
### A Coffeescript file with functions:
rails g coffeescript users show_all
Creates
window.users = do ->
init = ->
showAll = ->
return { init }
### A Sass file:
rails g sass users
Creates
.user
// Define sass here
### A Sass file with BEM elements:
rails g sass users name avatar
Creates
.user
// Define sass here
.user-name
// Define sass here
.user-avatar
// Define sass here
### An empty controller:
rails g controller users
Creates:
class Users < ApplicationController
end
### A controller with prepopulated actions:
rails g controller users new create show
Creates:
class Users < ApplicationController
def new
@user = users_scope.new
end
def create
@user = users_scope.new(user_params)
if @user.save
redirect_to(user_url(@user), notice: "Successfully created user")
else
render :new
end
end
def show
@user = users_scope.find(params[:id])
end
private
def users_scope
User.all
end
def user_params
params.require(:user).permit()
end
end
### A controller with actions and authentication:
rails g controller users new create show --authenticate admin
Creates:
class Users < ApplicationController
before_action :authenticate_admin!
def new
@user = users_scope.new
end
def create
@user = users_scope.new(user_params)
if @user.save
redirect_to(user_url(@user), notice: "Successfully created user")
else
render :new
end
end
def show
@user = users_scope.find(params[:id])
end
private
def users_scope
User.all
end
def user_params
params.require(:user).permit()
end
end
### A controller with a namespace:
rails g controller admins/users new create show --authenticate admin
Creates:
class Admins::Users < Admins::BaseControler
before_action :authenticate_admin!
def new
@user = users_scope.new
end
def create
@user = users_scope.new(user_params)
if @user.save
redirect_to(user_url(@user), notice: "Successfully created user")
else
render :new
end
end
def show
@user = users_scope.find(params[:id])
end
private
def users_scope
User.all
end
def user_params
params.require(:user).permit()
end
end
## Development
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/bodacious/orthodox.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).