L
L
lavezzi12015-08-13 17:04:00
Ruby on Rails
lavezzi1, 2015-08-13 17:04:00

Explain on your fingers how to create a status for an object?

Hello.
Let's say there is a note in the form of a task and you need to make several statuses for it, "in progress" and "completed". What is the best way to implement this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TyzhSysAdmin, 2015-08-13
@lavezzi1

Everything freed the head.
So so.
There are two, simple, options for implementing your task:
1. Add the "status" field to the model and implement select with predefined statuses in the form
2. the same thing, but create another "Status" model in the "ststus" field p.1 . store the "id" of the status
The second option is preferable, since it does not force you to add a new status to edit views or controllers if necessary, just add new statuses to the database.
quickly a project to figure out
https://github.com/POStroi/lavezzi1_toster
Well, no one bothers to put down the status with buttons, AJAX requests, and in general, whatever your heart desires :)

V
Viktor Vsk, 2015-08-13
@viktorvsk

1. manually make fields "in progress", 'readyh' ...
2. google ruby ​​state machine (ASM, Workflow gems)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question