Jump to content

The ultimate community for Ruby on Rails developers.


putting rails model and controller together


  • Please log in to reply
1 reply to this topic

#1 suyeshb



  • Members
  • 1 posts

Posted 18 January 2014 - 05:55 PM

i am new to rails.this is what i have done and trying to do, i have refills model and refills controller, user model and user controller, user model has phone number which i want to show in refills/new, just display.
What i want to learn and am confused with is, how to show various models info and stuff in views of other controllers? How do they relate each other? how to make them relate each other? Where do i put the methods for the parmas and how they are passed? for example, i have wallet model and wallet controller, when user refills through refill controller i want the amount deducted from wallet? how can i achieve that?   
i want to port a site that i use at work to rails, and learn in process. i am pretty familiar with ruby, and in railssome things just confuse me. rite now i am stuck at how to make models comunicate with each other. like i have refill model, wallet model, and user model, refill belongs to wallet, wallet belongs to user and has many refills, user has one wallet and has many refills through wallet. i have all tables set, but how do i make them work together, like when user refills, :balance from wallet will be deducted, and the refills witll go to user's :phone_number. what is the term called?    


how do i search it online? can you point me to links which talks about exactly that?


#2 panzhuli



  • Members
  • 3 posts

Posted 20 January 2014 - 12:58 AM

You can reference another Model in any other model or controller.... I recommend you watch some of the intro to rails videos on Ryan Bates' Railscasts website

Also tagged with one or more of these keywords: rails

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users