Skip to content
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

Transaction process 1/4: Add new schema, save new data to new schema #1035

Closed
wants to merge 6 commits into from

Conversation

rap1ds
Copy link
Member

@rap1ds rap1ds commented Mar 5, 2015

  • Create a TransactionProcess model
  • Each TransactionType has one TransactionProcess. Actually, the relation is belongs_to since the foreign key is in the TransactionType model
  • Save TransactionProcess in TransactionTypeCreator

- No it doesn't! But that's just the way Rails wants it to be. TransactionType contains the transaction_process_id foreign key. This is for the future, when we may want to change the process that is associated to the transaction type.
class CreateTransactionProcesses < ActiveRecord::Migration
def change
create_table :transaction_processes do |t|
t.string :process, null: false
Copy link
Contributor

Choose a reason for hiding this comment

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

btw. what do you think, should this string be limited from default 255?

@Gnito
Copy link
Contributor

Gnito commented Mar 5, 2015

👍


transaction_type = Object.const_get(type.to_s).create!(:type => type, :community_id => community.id)
transaction_type.create_transaction_process(process: opts[:process])
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be better to use create_transaction_process! as it throws instead of returning false on invalid association object.

- Add community_id to TransactionProcess
- Remove belongs_to and has_one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants