This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# (1) Is there something wrong with the following code: | |
class User < ActiveRecord::Base | |
scope :find_by_age, ->(age) { where("users.age = #{age}") } | |
end | |
# If yes, please tell why. If not, please tell how to order all records by id. | |
----- | |
Resp: yes, it's wrong. somebody forgot set '' for arg and AR will generate wrong select. | |
solutions: | |
scope :find_by_age, ->(age) { where("users.age = '#{age}"') } | |
or |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comment = | |
init: -> | |
do @deleteComment | |
do @newComment | |
newComment: -> | |
$('#contact #send').click (e) -> | |
e.preventDefault() | |
comment.addComment() |
NewerOlder