Hello everyone,
I have a situation where I need to send processed data from model to view.
Current working mechanism is, View (_form.html.erb)
I have a link <%= link_to “receipt summary”, receipt_rpts_create_path(from_date: ‘fdate’, to_date: ‘tdate’), :class => “btn btn-warning”, method: “get” %>
``
and some other text fields like share_amt, loan_balance etc, which needs to be updated later based on processed data received from the model.
which will send from date and to date to the controller (which is I’m not getting in correct format but I’ve checked whether parameters are received in controller by coding puts"#{fdate}" and its showing the output in stdout as fdate).
Both dates are received using “params[:from_date]” and "params[:to_date] and sent to model through controller as Controller (reciept_rpts_controller.rb)
ReceiptRpt.receiptsummary(fdate,tdate)
``
In the model I’ve self.receiptsummary(from_date, to_date) method, where I calculate share_amt, loan_balance, etc.
Now after calculating all those required values, I need to send share_amt and loan_balance etc back to view and update the view’s text field with these calculated values.
In basic rails app all these values which are processed in values are stored to database and then view (eg: index.html.erb) will fetch data from database and present to view. But in my situation I don’t need to store values to database. I want to show them on web page at that moment. How can I achieve this functionality?
Thank you.