Hi Padmahas,

Based on my understanding, you can return the processed values from model
to controller then to view like below sample definition.

/in controller
def create_reciept_summary
   @result = ReceiptRpt.receiptsummary(fdate,tdate)
end

/in model

def self.receiptsummary(fdate,tdate)
     ----calculation---
     return share_amt.to_s + ":" + loan_balance.to_s
end

/in view
<%  share_amt =   @result.split(":")[0] %>
<%  loan_balance =   @result.split(":")[1] %>

Hope it will help.


Regards,
Seeni Rafiyullah Khan A,
<[email protected]>*In Every moment, thank God.*

P Please consider the environment before printing this email

On Tue, Jun 21, 2016 at 1:50 PM, Padmahas Bn <[email protected]> wrote:

> 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.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/a3fef5db-313a-4dd1-8b7f-8ff064185545%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/a3fef5db-313a-4dd1-8b7f-8ff064185545%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CA%2BfXU%2B03fY22%3DHsRkGyZS%3DU7LDpvgt0dAijuE4yEWxRrb4nH_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to