Skip to main content

One form, two separate controllers, created at once.

Rails • Asked by Masud Hossain

I'm trying to create a sign_up form where the user will choose his email + password AND and Article at the same time as creating a user account.

So assentially, one form will create a new User and it will also create a new Article.

This is my new user form

<%= form_for(@user, url: registrations_path) do |f| %>

        <%= f.email_field :email %>

        <%= f.password_field :password %>

        <%= f.password_field :password_confirmation %>

        <%= submit_tag "Sign up", :class => "signupsubmit" %>

<%  end %>

And my new article form

<%= form_for(@article) do |f| %>

    <%= f.text_field :url  %>

    <%= f.submit "Submit"  %>

<% end %>

Essentially i want to combine these two forms into ONE.


you can use association between article and user and use nested attributes in it.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.