GithubHelp home page GithubHelp logo

frontier_generators's People

Contributors

osiro avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

jordanmaguire

frontier_generators's Issues

extra comma on belongs_to association

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.

Form generation for associations is broken.

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

Move shared example block out into shared group

  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

Generate sidebar link for menu options

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.

Migrations for attributes with different class names are broken

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

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.