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

ActiveInteraction::Base.new does not return a result of #to_model #463

Open
muraaano opened this issue Jun 28, 2019 · 2 comments
Open

ActiveInteraction::Base.new does not return a result of #to_model #463

muraaano opened this issue Jun 28, 2019 · 2 comments
Assignees

Comments

@muraaano
Copy link

I am implementing new action on Rails controller.

About Rails controller implementation for new action in README, it says that define #to_model and involve .new to get initialized model object.

But I checked this, .new return ActiveInteraction object not result of #to_model. Also #to_model was not involved. (It looks not involved from gem inside)

Can you tell me what should I do for new action ?

I involved #to_model from controller, then get my expectation. So it better to modify README as below ?

# GET /accounts/new
def new
  @account = CreateAccount.new.to_model
end

Environment

ruby '2.6.3'
active_interaction (3.7.1)

@AaronLasseigne
Copy link
Owner

The to_model method is called by the various form functions in Rails. You shouldn't have to pass it manually. Are you seeing an error when you just pass CreateAccount.new?

@simonmd
Copy link

simonmd commented Apr 25, 2020

I see the same thing with SimpleForm. Calling to_model explicitly works, otherwise it passes the interaction class.

  • ruby: 2.7.1
  • rails 6.0.2
  • active_interaction (3.8.2)
  • simple_form (5.0.2)

@AaronLasseigne AaronLasseigne self-assigned this Apr 26, 2020
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

No branches or pull requests

3 participants