I have a model called Project, which is a collection of information stored by a Company. This company can create projects two ways.
The first is the standard RESTful way – the company goes to the Project index, then clicks ‘New Project’, and upon creation is returned to the index with a flash message.
The second is a ‘quick create’ that can be accessed when a company is looking at a client’s profile. From here, the company can enter some basic information and send this off to create a project with that client (the client is specified automatically here).
The second of these two scenarios has a project being accessed from clients/show. Sending this data to projects/create would ordinarily route the company to projects/index, but I don’t want that. In this case, the create action is meaningfully different in that certain fields are treated differently, and the redirect is also different. What would you suggest I do?
- Build an alternative ‘create_from_client’ action in projects.
- Build a ‘create_project’ action in clients.
- Send a parameter to projects/create and set client_id and redirect to client/show if that parameter exists.
- Something else I’m not aware of.
Thanks!
I would just add another action to the controller, ‘quick_create’ or whatever. You can dry out the form with partials and parameters to the partial to tell how to render things…This just seems like the easiest way.
I’ve got this semi-rational (or is that semi-irrational) hang up against leveraging the referrer…