Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: labocho/rails-app-template
base: ef1541c4fb
...
head fork: labocho/rails-app-template
compare: 7e7306ca63
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
View
4 .cleancode
@@ -0,0 +1,4 @@
+---
+:include: ^(Rakefile|Gemfile|Capfile|Guardfile|config\.ru|.*\.(rb|erb|haml|yml|js|coffee|css|scss))$
+:exclude: ^(vendor/|public/|.*\.(eml)$)
+:force: false
View
2  README.md
@@ -3,4 +3,4 @@
## Usage
git clone git://github.com/labocho/rails-app-template
- rails new APP_PATH --template rails-app-template/template.rb --skip-test-unit
+ rails new APP_PATH --template rails-app-template/rails-app-template.rb --skip-test-unit
View
7 template.rb → rails-app-template.rb
@@ -104,6 +104,13 @@ def application_multiline(data, options = {})
EOS
# ====================
+# template
+# ====================
+
+rake "rails:templates:copy"
+directory(template_path + "generators", "lib/generators")
+
+# ====================
# git
# ====================
View
8 templates/generators/haml/scaffold/USAGE
@@ -0,0 +1,8 @@
+Description:
+ Explain the generator
+
+Example:
+ rails generate scaffold Thing
+
+ This will create:
+ what/will/it/create
View
10 templates/generators/haml/scaffold/scaffold_generator.rb
@@ -0,0 +1,10 @@
+require "rails/generators/erb/scaffold/scaffold_generator"
+
+class Haml::ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
+ source_root File.expand_path('../templates', __FILE__)
+
+ protected
+ def handler
+ :haml
+ end
+end
View
20 templates/generators/haml/scaffold/templates/_form.html.haml
@@ -0,0 +1,20 @@
+= form_for(@<%= singular_table_name %>, html: {class: "form-horizontal"}) do |f|
+ - if @<%= singular_table_name %>.errors.any?
+ %ul.alert.alert-error.validation-errors
+ - @<%= singular_table_name %>.errors.full_messages.each do |message|
+ %li= message
+
+ <%- attributes.each do |attribute| -%>
+ .control-group
+ = f.label :<%= attribute.name %>, class: "control-label"
+ .controls
+ = f.<%= attribute.field_type %> :<%= attribute.name %>
+ <%- end -%>
+ .control-group
+ .controls
+ = f.submit class: "btn btn-primary"
+ - if @<%= singular_table_name %>.new_record?
+ %a.btn{href: <%= index_helper %>_path} Cancel
+ - else
+ %a.btn{href: <%= singular_table_name %>_path} Cancel
+
View
3  templates/generators/haml/scaffold/templates/edit.html.haml
@@ -0,0 +1,3 @@
+%h1 Editing <%= singular_table_name %>
+
+= render 'form'
View
20 templates/generators/haml/scaffold/templates/index.html.haml
@@ -0,0 +1,20 @@
+%h1
+ = <%= singular_table_name.capitalize %>.model_name.human
+ .btn-group.pull-right
+ %a.btn{href: new_<%= singular_table_name %>_path} Add
+
+%table.table.table-bordered.table-striped
+ %thead
+ %tr
+ %th= <%= singular_table_name.capitalize %>.human_attribute_name :id
+ <%- attributes.each do |attribute| -%>
+ %th= <%= singular_table_name.capitalize %>.human_attribute_name :<%= attribute.name %>
+ <%- end -%>
+ %tbody
+ - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
+ %tr
+ %td
+ %a{href: <%= singular_table_name %>_path(<%= singular_table_name %>)}= "##{<%= singular_table_name %>.id}"
+ <%- attributes.each do |attribute| -%>
+ %td= <%= singular_table_name %>.<%= attribute.name %>
+ <%- end -%>
View
3  templates/generators/haml/scaffold/templates/new.html.haml
@@ -0,0 +1,3 @@
+%h1 New <%= singular_table_name %>
+
+= render 'form'
View
9 templates/generators/haml/scaffold/templates/show.html.haml
@@ -0,0 +1,9 @@
+<%- attributes.each do |attribute| -%>
+%dl
+ %dt= <%= singular_table_name.capitalize %>.human_attribute_name :<%= attribute.name %>
+ %dd= @<%= singular_table_name %>.<%= attribute.name %>
+<%- end -%>
+
+%a.btn{href: edit_<%= singular_table_name %>_path} Edit
+%a.btn.btn-danger{href: <%= singular_table_name %>_path(@<%= singular_table_name %>), "data-method" => "delete", "data-confirm" => "Are you sure?"} Delete
+%a.btn{href: <%= index_helper %>_path} Back

No commit comments for this range

Something went wrong with that request. Please try again.