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

Allow overriding model_name #319

Merged

Conversation

RobinClowers
Copy link
Contributor

This allows using different schemas for saving and loading data. My specific use case is wanting a create form to have extra fields that get saved in associated records. For example, when I create an order in the database, I want to use the CreateOrder module, which also creates line items. For the most part you can do this by overriding the controller action, but when you have validation errors, you need to pass that changeset into the form builder, which then generates the form with the wrong path (/admin/create_orders rather than /admin/orders). I wasn't really sure where to document this, can you point me in the right direction?

@RobinClowers RobinClowers force-pushed the make-model-name-configurable branch 2 times, most recently from 7b77de9 to 6a321d5 Compare March 13, 2017 23:11
def model_name(%{__struct__: name}) do
model_name name
if has_function?(resource, :model_name, 0) do
resource.model_name
Copy link
Owner

Choose a reason for hiding this comment

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

to avoid Elixir 1.4 warnings, I believe this should be resource.model_name()

@smpallen99
Copy link
Owner

I think a new section in the readme file would be the best way to document this. Please add that to the RP and I'll merge.

@RobinClowers RobinClowers force-pushed the make-model-name-configurable branch from 6a321d5 to a2b21b3 Compare March 28, 2017 02:16
@RobinClowers
Copy link
Contributor Author

@smpallen99 I addressed your feedback and rebased onto the latest master. Let me know if there is anything else.

@smpallen99 smpallen99 merged commit 4440300 into smpallen99:master May 14, 2017
@smpallen99
Copy link
Owner

Thanks!!

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.

2 participants