On Sunday, April 19, 2015 at 2:25:54 PM UTC+5:30, Padmahas Bn wrote: > > Hello all, I referred the rails guides from documentation section, but I > cannot solve this problem. > > Problem: > 1. I have member and receipt model (which should have corresponding > members and receipts table). > 2. Now I created a model called recovery to write some business logic. > (logic must be in models right?) > 3. And I have not created any association between any of the models. > > What I want to do: > 1. I just want to retrieve all the member_code from members table whose > 'status' is "active" from within *recovery model.* > 2. Once all member_code are available I want to compare those member_code > with the member_code of receipts table. If those member_code exists in > receipts table, I'll run some business logic only on those members. > > *So all I want to do is access the attributes of *members* and *receipts* > table from recovery model and I have created a button "start recovery > process" in view.html.erb of recoveries. I would like to execute the > business logic written inside recovery model once I press this button.* > How can I point the button to the code inside model? Because by default it > will pointing to actions inside controller right? > > Can I do this without creating associations? Or is it compulsory? > > Please help me >
Hello Collin Law, Thank you for replying. To make clear why I want to do above things, here are the details. And yes I started with railstutorials.org and I was able to create successful login page etc. But this is the logic part I'm trying to implement. Here is the details. 1. If I generate members model, then members table will be created in the database 2. If I generate recovery model, then recovery "-----------------"---------------------------". 3. And there is *no* association or any type of relation(one to many, has-many, belongs-to) between these two tables. Now is it possible to access data of members table such as member_code, member_status (active or inactive) etc from recovery model? If possible how? 1. I have members model and the table with so many attributes but right now I'm interested in member_code and member_status. 2. I have loan model and the table. Attributes I'm interested in are loan_type (joint loan or personal loan). 3. I have receipts table (Which contains the information of how much of the loan are already cleared by all members). 4. Now this is the special case. This model called recovery, I created it just because I read that business logic should be implemented inside the model and this model will calculate the remaining amount to be paid by each members. *May be members, loan and receipts table have association or relation between them, but in this recovery model all I want to do is just to read data from different tables and process the data and finally store them inside recovery table.* How can I achieve this ? -- 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 rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ac1d1e86-b668-479e-8338-e13a850fb7ef%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.