Activity Graph

Page 1 of 7 | Next »


[09:46:06] enricostn: has joined #RubyOnRails
[09:46:17] enricostn: has left #RubyOnRails: ()
[09:46:41] enricostn: has joined #RubyOnRails
[09:48:39] enricostn: has left #RubyOnRails: ()


[14:40:45] enricostn: hi there, is there any way to get a list of delayed jobs from Resque using Scheduler?
[14:41:37] enricostn: I can see the in the web UI but I need to access them from a console
[14:44:11] enricostn: universa1, mh good idea, I was expecting some Resque.whatever


[12:05:48] enricostn: hi there! I need to iterate over a big array retrieving a chunk of items at time until I reach the end of the array. For instance in the following example the chunk size is 5 https://gist.github.com/enricostano/21c0edbb5e2135a16542
[12:07:33] enricostn: I would like to understand how to achieve this with 2 constrains: it must be some lazy iteration because the array is big, I need to be able to skip elements (maybe this feature can be added later)
[12:09:08] enricostn: mh, yep actually the array is already there
[12:10:05] enricostn: the array is an array of objects that I retrieve from an external API
[12:10:47] enricostn: actually each chunk will be processed
[12:11:04] enricostn: this is a pattern matching algorithm
[12:12:26] enricostn: inside this external iteration I will look for a pattern in: first_chunk = [1,2,3,4,5]; then I'll try to match [1,2,3,4,5], if not [1,2,3,4] ,[1,2,3], etc
[12:12:37] enricostn: but that's the internal iteration
[12:13:24] enricostn: I've been trying but with not much luck... first time here with Enumerator
[12:33:04] enricostn: apeiros_, using your non-lazy solution, how I can change the offset and skip iterations?
[12:33:26] enricostn: like changing the i
[12:33:32] enricostn: by an offset
[12:40:24] enricostn: apeiros_, mh but my stepsize comes from inside the block that I pass to the yield
[12:40:49] enricostn: updating the gist with basic implementation
[12:47:17] enricostn: updated gist https://gist.github.com/enricostano/21c0edbb5e2135a16542
[13:09:00] enricostn: gregf__, thanks, I'll give it a try
[13:10:00] enricostn: gregf__, it seems so, but I'm having an hard time trying to skip iterations
[13:10:08] enricostn: my bad of course
[13:11:07] enricostn: apeiros_, sorry for the mess, I've updated the gist. should be clearer now. Thanks for your time BTW
[13:11:39] enricostn: ok sure, np


[14:13:05] enricostn: Hi there, I'm trying to figure out how to use rspec to test a Rails 4 engine using the dummy application but I cannot find any documentation about it
[14:13:16] enricostn: could please anyone point me to some documentation / tutorial ?
[14:13:37] enricostn: The only thing that I found is this http://stackoverflow.com/questions/8507798/rails-3-1-plugin-gem-dummy-test-app-rspec
[14:13:54] enricostn: but I keep getting uninitialized constant PublicPages::LandingController when I run rspec


[16:06:23] enricostn: hi there, I have a module Alfa that I need to extend in another module Beta and include it in a class Teta (that will be instantiated). The problem is that Alfa defines a default constant PAPPA that including/extending classes/modules should be able to override
[16:06:39] enricostn: like this https://gist.github.com/enricostano/c367aac670b574af93e0
[16:07:19] enricostn: Alfa has a method that call self::PAPPA
[16:07:35] enricostn: but I get <Teta:0x007f9b30b27028> is not a class/module (TypeError)
[16:08:09] enricostn: for the moment I just created a method in Alfa instead of a constant
[16:08:24] enricostn: so I can easily override it


[10:23:34] enricostn: hi there, can anyone please share some resource that illustrates how we can use "first/rest" aka "head/tail" recursively for an Enumerable?
[10:25:12] enricostn: For instance how to split (partition) an Array like [1, 2, 3] in [1, 2] and [3] based on a predicate like element == 2
[10:31:43] enricostn: Hanmac1, thanks but my predicate is more complex than el == 2
[10:32:03] enricostn: imagine an array of objects
[10:32:36] enricostn: I assume that the array is ordered
[10:33:07] enricostn: mh interesting
[10:47:47] enricostn: workmad3, what if I need to include the "pivot" element too? e.g. [1, 2, 3].slice_before{ |a| a == 2 }.to_a => [[1, 2], [3]]
[10:49:49] enricostn: would be interesting to see how we could achieve this using first/rest recursively


[13:20:32] enricostn: hi there, does in Rails exists a helper method to retrieve an ActiveRecord model knowing its type and id? eg. a string 'File' and an integer 3
[13:21:13] enricostn: I usually use case/when method to switch the type
[13:21:36] enricostn: and want to avoid meta as much as possible
[13:21:59] enricostn: some "greppable" way
[13:23:32] enricostn: well, I have a delayed background job that takes object_id and object_type and after some time I have to perform the job and I need to retrieve the object
[13:23:39] enricostn: that cold be of various types
[13:24:04] enricostn: say 'File', 'What', 'Ever'
[13:24:34] enricostn: so I generally use case/when
[13:25:15] enricostn: nope, because the object could have been deleted
[13:25:39] enricostn: so I just pass the ID and object type
[13:25:58] enricostn: then retrieve the object, check if it still exists
[13:26:05] enricostn: and perform my task
[13:27:48] enricostn: mh I don't know if Resque
[13:29:32] enricostn: so I find myself writing that case/when over and over in my code and I want to put it in some "helper" somewhere accessible... but then I thought that Rails must have something similar
[13:31:21] enricostn: my fault, sorry
[13:32:17] enricostn: yep, but with delayed jobs is almost usual
[13:33:16] enricostn: maybe Rails has some tricky method that uses when dealing with polymorphs


[16:42:07] enricostn: hi there, I have a function and I need to find the first element in an array that returns something from that function (not nil) and return that something


[16:03:37] enricostn: hi there, I'm unit testing a library in a Rails project and I'm trying to avoid creating models in DB (the FactoryGirl way)
[16:04:11] enricostn: but this library expects calling #where on an Active Relation
[16:04:47] enricostn: is there any elegant way to stub it?
[16:05:39] enricostn: I've found https://github.com/BenEddy/mock_relation but I was looking for a "native" Rails/RSpec solution
[17:55:59] enricostn: where I can find #where implementation for Array? hint: model.relation.class is Array
[17:56:19] enricostn: model.relation.where user_id: 12
[17:56:32] enricostn: but [].where doesn't of course
[17:56:57] enricostn: I cannot find it in ActiveSupport nor Active relation


[15:14:33] enricostn: I'm trying to do this Time.parse('([fe80::50:56ff:fe85:f0s]) ; Tue, 11 Mar 2014 07:30:41 -0500')
[15:14:50] enricostn: but I'm getting ArgumentError: argument out of range
[15:15:15] enricostn: It seems related to the presence of the 50:56ff bit
[15:17:38] enricostn: yep I'll try that. actually it's the content of a Received email header
[15:18:12] enricostn: but I should expect that the part after the last ; should be what I'm looking for


[23:02:13] enricostn: hi there! I'm trying out some REST API documentation tool, like Apipie. Any suggestion?
[23:03:31] enricostn: Radar, you mean even all the UI that allows you to send requests to the server, etc... ?
[23:04:41] enricostn: Radar, https://github.com/wordnik/swagger-core/wiki
[23:05:16] enricostn: Radar, https://github.com/Apipie/apipie-rails
[23:07:33] enricostn: Radar, so how do you solve the issue?
[23:09:58] enricostn: I see, but I'm looking for some nice UI where developers can play a bit with the API
[23:13:05] enricostn: it seems that you could build a Json and pass it to swagger that manages all the UI


[22:41:03] enricostn: hi there, I'm trying to install ruby-2.0.0-p353 on ArchLinux using RVM but I get the following error while compiling:
[22:41:22] enricostn: uncommon.mk:179: recipe for target 'build-ext' failed // make: *** [build-ext] Error 2
[22:42:24] enricostn: I think so, I've compiled other ruby versions before without issues
[22:44:26] enricostn: so no p353 on Arch?
[22:44:47] enricostn: maybe I could downgrade readline
[22:45:15] enricostn: I'll do that... I need p353
[22:45:49] enricostn: it's the version we use at work for this repo
[22:46:08] enricostn: so I can't pick another one
[22:48:05] enricostn: btw, many thanks jhass and centrx ! :)
[22:57:14] enricostn: jhass, downgrading readline (6.3-1 => 6.2.004-2) did the trick!
[22:57:57] enricostn: now I need to remember to upgrade it when the ruby issue is fixed...
[23:11:46] enricostn: whomp, http://rubyencoder.com/ and friends...
[23:15:01] enricostn: csmrfx, don't know I don't use it


[15:15:28] enricostn: hi there, I'm trying to unit test with RSpec a method similar to this one https://gist.github.com/enricostano/9135892
[15:15:54] enricostn: but it fails when I use let(:user) { double('User') }
[15:16:08] enricostn: if I use a real User object it works
[15:16:39] enricostn: I've tried to use target.class instead but then the real User object fails instead
[15:20:54] enricostn: jhass, thanks, yes raise of course
[15:21:17] enricostn: so I cannot use double() there?
[15:24:06] enricostn: I just don't want to use Factories there
[15:40:51] enricostn: jhass, what about this https://gist.github.com/enricostano/9135892
[15:47:14] enricostn: jhass, mh yeah I know. I didn't understand your suggestion btw


[19:44:41] enricostn: hi there, if I have 2 models namespaced like app/models/user.rb and app/models/role.rb and I want to create an association between User and Role
[19:44:50] enricostn: what association name should I use?
[19:45:01] enricostn: belongs_to :role
[19:45:48] enricostn: dachi, so if they are in the same namespace I should call it directly, right?
[19:47:12] enricostn: dachi, this is the line is puzzling me https://github.com/EppO/rolify/blob/master/spec/generators/rolify/rolify_activerecord_generator_spec.rb#L144
[19:47:20] enricostn: why :admin_user
[19:49:00] enricostn: dachi, ah ok, so I??? moving from habtm to has_many through
[19:49:25] enricostn: so it should be :users
[19:49:44] enricostn: because I need validation on the join model
[19:49:58] enricostn: http://kevmcnamee.com/blog/2012/11/07/why-you-dont-need-has-and-belongs-to-many-relationships/
[19:50:02] enricostn: for instance
[19:51:03] enricostn: centrx, why?
[19:51:34] enricostn: with habtm you get a join table but you cannot add validations on it
[19:52:05] enricostn: no, I need it now XD
[19:52:41] enricostn: yep, that?? why I'm moving to has_many through


[22:47:33] enricostn: hi there, how could I get datetime ISO format calling #as_json ? Now I get https://gist.github.com/enricostano/8378025
[22:48:04] enricostn: I wish I could get something like updated_at"=>"2014-01-11T22:28:49.219Z
[22:48:49] enricostn: as the render :json do in controller
[22:54:44] enricostn: centrx, yep I was expecting that Rails gives the same format in both cases, controller rendering as json an calling model.as_json
[22:56:44] enricostn: centrx, I saw those links thanks. but I don't like the monkey patch solution
[22:57:06] enricostn: it should use the same format in both cases
[23:01:30] enricostn: centrx, I mean this #as_json http://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html#method-i-as_json
[23:03:06] enricostn: yep see my gist
[23:03:20] enricostn: #as_json call #serializable_hash
[23:03:59] enricostn: https://github.com/rails/rails/blob/019df9887519701b321c668c1d27d5c0c26fee7a/activemodel/lib/active_model/serialization.rb#L97
[23:04:56] enricostn: yep, I was just wondering if there is a built in Rails 4 way
[23:06:10] enricostn: here is my controller https://github.com/coopdevs/katuma/blob/add-group-controller-spec/app/controllers/api/v1/groups_controller.rb#L13
[23:10:55] enricostn: centrx, using render @group.as_json imply that you??l use a view
[23:11:03] enricostn: and it's not my case
[23:11:43] enricostn: if I use it actually fails asking for a view
[23:14:27] enricostn: but I'm still digging the code
[23:15:55] enricostn: but it's not a hash
[23:16:00] enricostn: but it's something :)
[23:16:52] enricostn: I'm using JSON.parse in my tests, it's more readable
[23:19:03] enricostn: centrx, mostly there https://gist.github.com/enricostano/8378025#file-gistfile2-txt
[23:20:28] enricostn: yep that's the #index
[23:20:41] enricostn: #show works now
[23:22:24] enricostn: centrx, it works now but with an ugly hack:
[23:22:28] enricostn: expect(api_response.body).to eq("[#{group.to_json}]")
[23:23:06] enricostn: I wish I could use JSON.parse there
[23:23:51] enricostn: btw many thanks!
[23:25:00] enricostn: centrx, here is my diff https://gist.github.com/enricostano/8378025#file-gistfile3-diff
[23:30:58] enricostn: centrx, better now https://gist.github.com/enricostano/8378025#file-gistfile4-diff-L10
[23:31:07] enricostn: I didn't like that string interpolation


[14:25:30] enricostn: hi, is there a way to pass a variable to a FactoryGirl callback block in a trait? like this one https://gist.github.com/enricostano/8268768#file-factories-rb-L8
[14:25:40] enricostn: I need to pass that "group"
[14:32:58] enricostn: jalcine, thanks, what I don't understand is if I'm adding the callback in a trait de ignore block should go inside the trait or not
[14:33:20] enricostn: FactoryGirl.create :user, :group_admin, group: group
[14:33:35] enricostn: that's wat I'm trying to achieve
[14:35:08] enricostn: gist updated https://gist.github.com/enricostano/8268768
[14:35:43] enricostn: jalcine, a FactoryGirl alias?
[14:37:03] enricostn: looking into thanks!
[14:39:21] enricostn: jalcine, I still get undefined method `group=' for #<User:0x000000057787d8>
[14:40:58] enricostn: ooh ok thanks!
[14:42:10] enricostn: jalcine, and I still could create a group factory there instead of group=nil, I suppose.. right?
[14:42:35] enricostn: so If I don't pass a group it'll create one..
[14:43:19] enricostn: is there a better way than calling directly FactoryGirl.create method?
[14:43:26] enricostn: I mean in there
[14:43:33] enricostn: in ignore do block
[14:44:52] enricostn: btw undefined method `group=' for #<User:0x0000000478e4a8>
[14:46:29] enricostn: yep using evaluator I??l update the gist
[14:47:52] enricostn: jalcine, https://gist.github.com/enricostano/8268768
[14:50:38] enricostn: jalcine, https://gist.github.com/enricostano/8268768#
[14:50:45] enricostn: look at the comment
[14:52:51] enricostn: https://gist.github.com/enricostano/8268768
[14:53:46] enricostn: jalcine, removing it I get the same error...
[14:59:13] enricostn: jalcine, no way same errror
[14:59:31] enricostn: this is an opensource project may I point you to the full PR?
[15:09:18] enricostn: jacky, sorry I had to push some commit... https://github.com/coopdevs/katuma/pull/21
[15:10:37] enricostn: jacky, you could see the failures in travis too https://travis-ci.org/coopdevs/katuma/builds/16416336
[15:27:01] enricostn: jacky, great, thanks!
[15:27:32] enricostn: yep that would be great too, I've planned to add it
[15:28:14] enricostn: but I cannot do all the things this project need :(
[15:28:42] enricostn: I'm the only backend guy here :/
[15:35:17] enricostn: ooo I got it...
[15:35:28] enricostn: that's no group = nil
[15:35:44] enricostn: it should be group create(:group)
[15:36:49] enricostn: I'll post the updates
[15:38:39] enricostn: jacky, https://github.com/coopdevs/katuma/commit/3f3be55e5366dc20cbeae1c8b497c0ceb024b6d3
[15:39:07] enricostn: group must be of Group type
[15:39:22] enricostn: and there is no "="
[15:39:29] enricostn: is a classic factory attribut assignment
[15:39:34] enricostn: with no "="
[15:40:21] enricostn: many thanks for your time btw!
[16:07:28] enricostn: ah ok sure! :)


[19:48:57] enricostn: what I need to do is: when I create a new Group it should create an associated UsersUnit too with the name passed in params... but if I don't receive users_unit_attributes in params I should be able to create the associated UsersUnit generating the name with a method
[19:52:34] enricostn: RubyRonin, it runs the server in background
[19:54:31] enricostn: just remember to kill it when you don't need it anymore
[19:59:52] enricostn: operating system?
[20:01:37] enricostn: ah ok maybe that's the problem
[20:03:07] enricostn: RubyRonin, It is failing because Windows Operating System doesn't implement a fork system call.
[20:08:25] enricostn: ddd, ok I??l try it thanks!
[20:12:48] enricostn: ddd, to be sure that I receive users_units_attributes in params I could use validate presence of :users_units in Group model, right?
[20:14:24] enricostn: ddd, in that way I delegate to the JS client the "Group without a specified users unit name" edge case
[20:14:55] enricostn: yeah that's what I'm doing right now
[20:23:00] enricostn: ddd, I??? trying to test (RSpec + FactoryGirl) the Group model
[20:23:35] enricostn: ddd, but I don't understand how to create the factory
[20:23:37] enricostn: https://github.com/coopdevs/katuma/blob/role-based-authorization/spec/factories.rb#L23
[20:24:07] enricostn: googling I find solutions a bit smelly
[22:10:21] enricostn: is there a way to limit accept_nested_attribute_for only for updates in has_many assocs?
[22:10:55] enricostn: :update_only is for one2one assocs only :(