If you will find any record by id or something else then, if the record would not be present find will return Exception error it can break your application. find a user who is not in a database like this:
User.find(:id=>6)
it's wrong to find data. Now try where instead of find because if the record would not be present where will return Nil it will not break your application. find a user who is not in a database like this:
User.where(:id=>6).first
That's why use where to get the record to the database in rails :)
User.find(:id=>6)
it's wrong to find data. Now try where instead of find because if the record would not be present where will return Nil it will not break your application. find a user who is not in a database like this:
User.where(:id=>6).first
That's why use where to get the record to the database in rails :)
Nice.
ReplyDeleteSoftware tester We always follow the latest trends in IT world and update our syllabus based on that information. Our students graduate with the knowledge of the latest technology that is used in Software Development and QA.
ReplyDelete