Skip to content

Instantly share code, notes, and snippets.

View pecha7x's full-sized avatar
🚀

Artyom Pechyorin pecha7x

🚀
View GitHub Profile
@pecha7x
pecha7x / response
Last active October 25, 2015 18:50
# (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
comment =
init: ->
do @deleteComment
do @newComment
newComment: ->
$('#contact #send').click (e) ->
e.preventDefault()
comment.addComment()