Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Confused between using multiple models or controller


  • Please log in to reply
1 reply to this topic

#1 Andy Britton

Andy Britton

    Passenger

  • Members
  • 1 posts

Posted 04 November 2013 - 03:34 PM

I'm new to rails and programming in general, I understand frontend development but when it comes to backend I'm still learning.

 

I'm trying to create a rails app that allows users to submit information about pets.  I've come to a point where my knowledge is limited and I don't know enough about what/how this could be done so I'm hoping this will be relatively easy to answer.

 

At the moment I have a model called Pet, this model currently stores basic information like name, picture etc but it also holds more specific data like type, breed, date of birth etc.  What I would like to be able to do is create a page that can match various records without having to be manually categorized if that makes sense so a users pet could be matched to other pets with the same breed, age etc.  I've read about nested models as I understand this information could be submitted to 2 models in one form but I am not sure whether this could be done directly in a separate controller which would only be visible to users with pets in these matched "groups" if that makes sense.  

 

So in essence can I use 1 table to store all the information about a users pet and just use a controller to match pets based on rows having the same values or would it be far simpler to have a form with a nested model and link 2 tables together?  The main feature needs to be matching without a user having to create a group or categorize pets.

 

Thanks in advance.

 

 



#2 james

james

    Guard

  • Moderators
  • 221 posts
  • LocationLeeds, U.K.

Posted 04 November 2013 - 11:38 PM

Well, I have read your question several times and I just don't understand what you are trying to achieve when you say

What I would like to be able to do is create a page that can match various records without having to be manually categorized if that makes sense so a users pet could be matched to other pets with the same breed, age etc

 

 

I suspect you are struggling because you don't have a clear 'use case'

 

Perhaps if you came back with a clearly defined set of use cases I (and others) would be able to give you a concise and accurate answer but as it is any answers would be pure guesses with the info you have provided. I also suspect that once you have defined your use cases you probably won't need any help :)

 

Anyway, can you clarify the process that you want to achieve


Programming is just about problem solving!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users