Z
Z
zggb2014-10-28 16:19:10
Ruby on Rails
zggb, 2014-10-28 16:19:10

Is it possible to do without a database in a search form?

There is an option not to use a database in this case:
The data from the form is stored in a ruby ​​variable, which is then used in the same #iframe#, for example.
Or you need to save the result of the form in the database, work with it, and then automatically delete the value (in some way).
How, on the same page, to display the value received in the form, for example, through form_for?
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolai, 2014-10-28
@zggb

You need to save something in the database only if you will request it from it.
params in templates works, but this is bad form, it's better to make a regular model, as usual. If you are embarrassed by the fact that an empty table will hang in the database, this is fixable, but I think that at this stage it is better for you not to mess with it.
def action
@car = Car.new
# It's better not to do this in controllers, but let's not go beyond the question
@car.name = params[:name]
@car..price = params[:price]
end
Next, in the form_for template @car, ...

V
Viktor Vsk, 2014-10-28
@viktorvsk

Concept of what? What is the task?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question