-
Notifications
You must be signed in to change notification settings - Fork 1
Changes models #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes models #29
Conversation
app/models/contract.rb
Outdated
| validates :start_date, presence: true | ||
| validates :finish_date, presence: true | ||
| belongs_to :space | ||
| has_many :contract_spaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has_and_belongs_to_many :spaces
http://guides.rubyonrails.org/association_basics.html#the-has-many-association
2.6 The has_and_belongs_to_many Association
A has_and_belongs_to_many association creates a direct many-to-many connection with another model, with no intervening model. For example, if your application includes assemblies and parts, with each assembly having many parts and each part appearing in many assemblies, you could declare the models this way:
| @@ -0,0 +1,5 @@ | |||
| # ContractSpace | |||
| class ContractSpace < ApplicationRecord | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esta clase no es necesaria.
app/models/space.rb
Outdated
| has_many :children, inverse_of: :parent, foreign_key: :space_id, class_name: 'Space' | ||
| has_many :contracts | ||
| has_many :assets | ||
| has_many :contract_spaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has_and_belongs_to_many :contracts
http://guides.rubyonrails.org/association_basics.html#the-has-many-association
2.6 The has_and_belongs_to_many Association
A has_and_belongs_to_many association creates a direct many-to-many connection with another model, with no intervening model. For example, if your application includes assemblies and parts, with each assembly having many parts and each part appearing in many assemblies, you could declare the models this way:
| t.datetime "updated_at", null: false | ||
| end | ||
|
|
||
| create_table "payments", force: :cascade do |t| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ create_table "payments", force: :cascade do |t|
- t.integer "payment"
+ t.date "due_date"
+ t.date "payment_date"
- t.date "warning_date"
+ t.decimal "amount"
+ t.string "status"
+ t.text "note"
spec/models/payment_spec.rb
Outdated
| require 'rails_helper' | ||
|
|
||
| RSpec.describe Payment, type: :model do | ||
| it 'is valid with a payment, payment date, quantity and status' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactorizar en 1 sola linea de código.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app/models/space.rb
Outdated
| end | ||
| end | ||
|
|
||
| # def generate_full_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nunca incluir código comentado.
app/models/space.rb
Outdated
| protected | ||
|
|
||
| def generate_full_name | ||
| new_name = name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new_name, next_parent = name, parent
app/models/space.rb
Outdated
| def generate_full_name | ||
| new_name = name | ||
| next_parent = parent | ||
| while next_parent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new_name, next_parent = "#{parent.name} | #{new_name}", next_parent.parent while next_parent
| @@ -0,0 +1,5 @@ | |||
| class RemoveReferencesOnContract < ActiveRecord::Migration[5.1] | |||
| def change | |||
| remove_reference(:contracts, :space, index: true) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identación
config/initializers/rails_admin.rb
Outdated
| # history_show | ||
| end | ||
| config.model 'User' do | ||
| list do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config.model 'User' { list { configure :id { hide } } }
|
@cxasper finish this PR to merge it to master. |
|
@cxasper status? merge this PR to master |
|
@cxasper status? |
No description provided.