thefrontiergroup / frontier_generators Goto Github PK
View Code? Open in Web Editor NEWRails generators to be used to quickly scaffold CRUD for models in the Rails Template
Rails generators to be used to quickly scaffold CRUD for models in the Rails Template
See: El Mulcho
The following yaml:
address:
attributes:
line_1:
type: "string"
validates:
presence: true
line_2:
type: "string"
suburb:
type: "string"
validates:
presence: true
postal_code:
type: "string"
validates:
presence: true
state:
type: "belongs_to"
validates:
presence: true
Generated:
class Address < ActiveRecord::Base
# Soft delete - uses deleted_at field
acts_as_paranoid
belongs_to :state,
validates :line_1, presence: true
validates :suburb, presence: true
validates :postal_code, presence: true
validates :state, presence: true
def to_s
line_1
end
end
Didn't have enough time to look into that, but I think it's something to do in here: https://github.com/thefrontiergroup/frontier_generators/blob/master/lib/model_configuration/association.rb#L40
BTW, in newer versions of Rails, we do not need to do validates :state, presence: true
, we can pretty much do belongs_to :state, required: true
.
Thought about changing the generators to validates associations with require true.
Looks like https://github.com/stevehodgkiss/generator_spec should do the trick. Some brief testing has shown this should work.
EG:
= f.input :height_in_cm, input_html: {min: 0, max: 1}
I guess you'd need to add constants to the model and reference them:
# in model
HEIGHT_IN_CM_MIN = 0
HEIGHT_IN_CM_MAX = 1
Gonna be a rough one.
EG:
resources :dongs, only: :index
resources :umbrellas, only: [:index, :show]
In rails 5 migrations with timestamps require null: false. See:
http://juanitofatas.com/2015/01/28/rails-5-timestamps/
Currently the generators can't do this. There is currently no way to specify null constraints from the command line.
= f.input :given_names, autofocus: true
PS:
Fuck pundit
YOLO
Always creates using admin namespace
interview_questionnaire:
namespaces: ["member"]
skip_seeds: true
attributes:
address:
show_on_index: false
type: belongs_to
generates..
= simple_form_for [:member, @interview_questionnaire], wrapper: "horizontal", html: {class: "form-horizontal"} do |f|
= f.association :address_id, collection: Address.all
.form-actions
= f.button :submit
%span.or or
= link_to "Cancel", member_interview_questionnaires_path
instead of
= simple_form_for [:member, @interview_questionnaire], wrapper: "horizontal", html: {class: "form-horizontal"} do |f|
= f.association :address, collection: Address.all
.form-actions
= f.button :submit
%span.or or
= link_to "Cancel", member_interview_questionnaires_path
If I define an attribute has having presence: true, it would be great if the migration could automatically add null: false to the column.
shared_examples_for "Policy without access to CRUD actions" do
it { should_not permit_access_to(:index) }
it { should_not permit_access_to(:new) }
it { should_not permit_access_to(:create) }
it { should_not permit_access_to(:edit) }
it { should_not permit_access_to(:update) }
it { should_not permit_access_to(:destroy) }
end
It's time to make this map pretty hard to the rails template so that we can save more time.
Add option include_sidebar_link that defaults to true to support this implementation.
Probably as an option. (Default: off)
interview_questionnaire:
namespaces: ["member"]
skip_seeds: true
attributes:
gp_address:
show_on_index: false
type: belongs_to
class_name: "Address"
will generate the following migration
class CreateInterviewQuestionnaire < ActiveRecord::Migration
def change
create_table :interview_questionnaires do |t|
t.belongs_to :gp_address, index: true, foreign_key: true
t.datetime :created_at
t.datetime :updated_at
t.datetime :deleted_at
end
add_index :interview_questionnaires, :deleted_at
end
end
This will fail PGError: ERROR: relation “gp_address” does not exist
. The migration requires a 'references' component, which you can't use foreign_key: true on :/. Migration should end up looking like this for it to work.
class CreateInterviewQuestionnaire < ActiveRecord::Migration
def change
create_table :interview_questionnaires do |t|
t.belongs_to :gp_address, references: :addresses, index: true
t.datetime :created_at
t.datetime :updated_at
t.datetime :deleted_at
end
add_index :interview_questionnaires, :deleted_at
add_foreign_key :interview_questionnaires, :addresses, column: :gp_address_id
end
end
Generator currently blows up if blank.
Gives [,@object]
rather than just @object
skip_ui: true
# or
skip_ui:
skip_index: true
skip_new: true
skip_edit: true
# or
skip_ui: [:index, :new, :edit]
this should apply to controllers:
protected
# Override: Admin::BaseController
def default_sort_options
{created_at: :desc}
end
[:yolo] is not valid YAML
Mimic changes in:
File is required for passenger to behave with RVM
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.