jose_leeto

Activity Graph

Page 1 of 1

2017-05-02

[19:57:30] jose_leeto: has joined #ruby
[20:00:50] jose_leeto: some one knows if it is possible to use a rails validation method on a delegated attribute?
[20:02:43] jose_leeto: Quit: Leaving.

2017-03-30

[12:59:34] jose_leeto: has joined #RubyOnRails
[21:58:06] jose_leeto: Quit: Leaving.

2017-03-29

[13:37:39] jose_leeto: has joined #RubyOnRails
[13:38:26] jose_leeto: there is a default way to prevent change a model attribute once it is different than nil?
[17:13:15] jose_leeto: there is a default way to prevent change a model attribute once it is different than nil?
[22:37:08] jose_leeto: Quit: Leaving.

2017-03-07

[21:03:44] jose_leeto: Ping timeout: 260 seconds

2014-09-06

[00:01:11] jose_leeto: pipework, I have controll of string I will save that like a json
[00:01:31] jose_leeto: it is better than use eval
[00:02:38] jose_leeto: I can call to_json method too

2014-09-05

[16:43:15] jose_leeto: hello iamvfl
[16:43:21] jose_leeto: how are you?
[16:44:26] jose_leeto: any one knows how can I passa a param to the left join?
[16:46:12] jose_leeto: I want to make like where
[16:46:31] jose_leeto: pass params to the condition using prepare statement
[16:47:44] jose_leeto: something like, Publication.joins("LEFT JOIN likes ON likes.publication_id = publication.id AND likes.user_id = :user_id", user_id: current_user.id)
[16:48:56] jose_leeto: but this dont work centrx
[16:49:51] jose_leeto: centrx, I think not
[16:50:03] jose_leeto: I dont see it in any place
[16:50:18] jose_leeto: but I need a way to do that
[16:50:55] jose_leeto: centrx, the consult above
[16:51:04] jose_leeto: or somethink similar
[16:51:32] jose_leeto: I want to know in every single publication if the current user has liked it
[16:52:55] jose_leeto: centrx, to know it I need to made the left join with the table likes if the result of join fot that publication was diferent to nil the user liked the publication
[16:54:06] jose_leeto: do not have likes, or do not have likes?
[16:55:30] jose_leeto: no I want list all publications and know if the current user like or not each of then
[16:57:26] jose_leeto: centrx do you get it?
[17:00:14] jose_leeto: a single query is better for the organization and I will sure that the data are correct
[17:01:17] jose_leeto: two separate queries I need to check the data integrity between
[17:01:34] jose_leeto: but if is no other way I will do two queries
[17:04:06] jose_leeto: so how can I pass the user id to the select?
[17:06:09] jose_leeto: centrx, yes a get it, but I mean in code how I will safe pass the param
[17:06:58] jose_leeto: centrx, the only way appears to be concat the join string, but I dont like to concat sql string
[17:13:33] jose_leeto: raise "ActiveRecord::ConfigurationError: 1" this error
[17:15:27] jose_leeto: you know if rails really support this type of sintax in joins too?
[17:19:52] jose_leeto: https://gist.github.com/fariasvp/07a1e28d5dbbcdc42abf
[17:20:42] jose_leeto: tubbo, I just want to know how I can pass a param to the left join
[17:22:23] jose_leeto: centrx, I think it is not a issue with my association becouse when I test on the string in joins method everything work fine.
[17:22:50] jose_leeto: I mean, when I test the param hardcoded
[17:36:35] jose_leeto: centrx, can you check it? https://gist.github.com/fariasvp/07a1e28d5dbbcdc42abf
[17:46:18] jose_leeto: centrx, do you have any ideia?
[17:47:11] jose_leeto: pipework, could you give me a good ideia?
[17:47:19] jose_leeto: https://gist.github.com/fariasvp/07a1e28d5dbbcdc42abf
[17:47:19] jose_leeto: about this case
[17:49:24] jose_leeto: centrx as I said when I pass only a string every thin work as expected
[17:51:35] jose_leeto: centrx I dont understand how it could be a associations issue
[17:53:13] jose_leeto: centrx if it was a association issue the first consult shouldn't work
[17:54:18] jose_leeto: it is like made a where("user = 1") and where("user = :user", user:1) and just the first work
[17:58:36] jose_leeto: centrx I really think that activerecord dont suport that sintax in joins method
[17:59:40] jose_leeto: centrx so it is a bug
[18:00:32] jose_leeto: centrx there is no safe way to pass a param to joins clause
[18:00:51] jose_leeto: tubbo, yes I tried it too
[18:01:08] jose_leeto: tubbo and it still return a error but a diferent one
[18:02:05] jose_leeto: centrx good ideia
[18:02:48] jose_leeto: tubbo really?
[18:02:50] jose_leeto: tubbo where?
[18:03:39] jose_leeto: tubbo why AND it not valid for that join?
[18:04:26] jose_leeto: tubbo yes I want all publications and know if there are a like made by that user
[18:04:30] jose_leeto: tubbo do you get it?
[18:05:05] jose_leeto: tubbo using where?
[18:06:23] jose_leeto: tubbo no in this case I will get only the publications that the user like
[18:07:18] jose_leeto: tubbo I want all publications and know for each one of then if user liked it
[18:08:07] jose_leeto: tubbo, Publication.joins("LEFT JOIN likes ON likes.publication_id = publication.id AND likes.user_id = 1").select("publication.*, like.id AS has_liked")
[18:08:36] jose_leeto: tubbo if has_like is diferent to nil the user like publication
[18:09:10] jose_leeto: tubbo do you get it?
[18:13:31] jose_leeto: centrx find_by_sql works fine :D
[18:14:02] jose_leeto: tubbo to get the likes.id param
[18:14:57] jose_leeto: tubbo if "Publication.joins("LEFT JOIN likes ON likes.publication_id = http://publication.id/??AND likes.user_id = 1").select("publication.*, http://like.id/??AS has_liked").first.has_liked" return nil the user dont like the publication in other case he liked it
[18:15:27] jose_leeto: centrx but I still think there is a issue in rails joins
[18:30:45] jose_leeto: centrx do you know why they made that decision?
[18:33:45] jose_leeto: centrx the interpolation with #{} makes me vunerable to sql injectio
[23:51:11] jose_leeto: any one knows how can I convert this string '{"id"=>2, "name"=>"my name"}' into hash?

2014-08-28

[20:45:09] jose_leeto: any one know how can a search the models created at in the current hour?
[20:48:04] jose_leeto: but how is the best way to get the start and final of the hour