Please read for an updated status on RailsCasts:
Learn more or hide this
On this topic "Move Find into Model", I have queries which I hope you could help to enlighten me:
I provide CRUD of books. First, user will have to select the action (i.e. C, R, U or D) from the menu. Then, a search screen is displayed for user to enter the book title/s which s/he would like to check.
The search string could contain more than one word, * (0 or more character wild card), ? (single character wild card) and so on.
In this case, should the formatting and validation of the search string be also embedded in the Book model, together with the Find in the Book model? If not, where should this be included?
Thank you for your help.
@Lucky, yes, I would put the handling of the search wild cards into the model. That's logic that doesn't belong in the controller.
I am curious about the self.find...
Why is it that this method requires "self." ?
I found an answer to something that has been confounding me about the self. thing. I am learning about OO programming, so I admit that this may seem obvious to a lot of people. Please excuse my ignorance.
Here is a link regarding how this works.
Thank you Ryan for all the excellent work in your railscasts. I really appreciate the patience and clear mindedness that you demonstrate in your screencasts. You express yourself as a joyful and brilliant person.
i know this is wrong place to write this but i need a solution i want to know how mapping should be done mine case is " A has many B , A has many C, every B has some C which is added to above list which is related to A. so tell me the way to map them . i have mapped B and C to A
I'm a newbie to rails and adding this post to clarify the railscast. I was wondering why the def was called "self.find_incomplete" when the original code was "find_all_by_complete". It took me a few minutes, but it's called "incomplete" because the data being queried is a boolean condition and the query is looking for the "false" conditions (i.e. tasks that are not completed) ergo the naming if "incomplete". Yes, a Homer Simpson DOH! moment...
Isn't named_scope a better way to implement the same?
Definitely. Or just "scope" as it is now.
Man, this is just begging to be revised! :)
Couldn't you use a 'scope' for this?
Edit: @Ryan L. Cross: +1
The second episode of Railscast is now updated for Rails 4.2.5 as a blog post. Check out the Active Record Basics
First sign in through GitHub to post a comment.