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
Conversation
- 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 |
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.
btw. what do you think, should this string be limited from default 255?
👍 |
|
||
transaction_type = Object.const_get(type.to_s).create!(:type => type, :community_id => community.id) | ||
transaction_type.create_transaction_process(process: opts[:process]) |
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.
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
belongs_to
since the foreign key is in the TransactionType model