Skip to content

Changes models#29

Open
cxasper wants to merge 13 commits into
masterfrom
changes-models
Open

Changes models#29
cxasper wants to merge 13 commits into
masterfrom
changes-models

Conversation

@cxasper

@cxasper cxasper commented Feb 12, 2018

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread app/models/contract.rb Outdated
validates :start_date, presence: true
validates :finish_date, presence: true
belongs_to :space
has_many :contract_spaces

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member

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.

Comment thread 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

Copy link
Copy Markdown
Member

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:

Comment thread db/schema.rb
t.datetime "updated_at", null: false
end

create_table "payments", force: :cascade do |t|

Copy link
Copy Markdown
Member

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"

Comment thread 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

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread app/models/space.rb Outdated
end
end

# def generate_full_name

Copy link
Copy Markdown
Member

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.

Comment thread app/models/space.rb Outdated
protected

def generate_full_name
new_name = name

Copy link
Copy Markdown
Member

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

Comment thread app/models/space.rb Outdated
def generate_full_name
new_name = name
next_parent = parent
while next_parent

Copy link
Copy Markdown
Member

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identación

Comment thread config/initializers/rails_admin.rb Outdated
# history_show
end
config.model 'User' do
list do

@lshimokawa lshimokawa Feb 12, 2018

Copy link
Copy Markdown
Member

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 } } }

@lshimokawa

Copy link
Copy Markdown
Member

@cxasper finish this PR to merge it to master.

@lshimokawa

Copy link
Copy Markdown
Member

@cxasper status? merge this PR to master

@moisesnandres

moisesnandres commented Apr 6, 2018

Copy link
Copy Markdown
Contributor

@cxasper status?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants