ali_g

Activity Graph

Page 1 of 1

2018-08-01

[00:56:06] ali_g: has joined #ruby
[00:58:57] ali_g: Hello, everyone! can somebody help me with this one? https://gist.github.com/ponentesincausa/fc3e94bd48392f1b213e862d74dadec1
[00:59:42] ali_g: I am using map because that variable may sometimes collect several amount keys
[01:01:12] ali_g: if I h["amount"] it throws "700", why would the result be ["amount", "700"]["amount"]?
[01:11:49] ali_g: @havenwood I am seeing my mistake now, I thought I was grabbing a value from the key but I wasn't, I ended up with two array of 2 values. I can't use .first because the h in the example will be changing sometimes including more than one "amount" value, but I conclude from what you are saying that map is the wrong tool for this
[01:14:25] ali_g: I'm looking to return an array with all the values for amount converted to string
[01:14:32] ali_g: sorry, converted to float
[04:15:22] ali_g: Quit: Connection closed for inactivity

2018-03-14

[06:07:29] ali_g: Quit: Connection closed for inactivity

2018-03-13

[22:45:01] ali_g: has joined #ruby
[22:45:27] ali_g: has joined #RubyOnRails

2018-03-02

[04:11:06] ali_g: Read error: Connection reset by peer
[04:15:21] ali_g: has joined #ruby
[04:49:02] ali_g: Quit: Connection closed for inactivity

2018-03-01

[18:59:16] ali_g: has joined #ruby
[18:59:56] ali_g: has joined #RubyOnRails
[19:03:11] ali_g: Hi all! has anybody tried renaming a URL for a single route in devise? I need the url for the edit_user_registration changed to account_settings but don't know where to start.
[19:03:55] ali_g: well i do know where
[19:04:02] ali_g: actually. I changed it to get 'account_settings', to: 'devise/registrations#edit'
[19:04:42] ali_g: and it worked as changing the URL goes but now I got an undefined method `validatable?' for nil:NilClass and I'm not sure if it's related or if I should threat it as a separate issue
[19:36:35] ali_g: perrrfect @mroutis! that it exactly what I was searching for. And apparently yes, that was what was messing up my devise config
[19:36:41] ali_g: Thank you!

2018-02-09

[19:45:01] ali_g: has joined #ruby
[19:48:56] ali_g: hello all! not sure if proper channel but i'm using jekyll. I'm trying to put a list of items in 3 different divs. It shouldn't be so difficult but I'm printing a single concatenated line with all the items of the list and don't understand why. Can anybody help? here's the gist: https://gist.github.com/ponentesincausa/760b687acbd76c35665f4b87466a4b7f

2018-01-18

[00:16:32] ali_g: Read error: Connection reset by peer
[00:17:43] ali_g: has joined #RubyOnRails
[00:57:24] ali_g: Read error: Connection reset by peer

2018-01-17

[03:40:30] ali_g: has joined #RubyOnRails
[07:04:08] ali_g: Quit: Leaving.
[15:21:41] ali_g: has joined #RubyOnRails
[19:39:11] ali_g: Quit: Leaving.
[20:01:53] ali_g: has joined #RubyOnRails
[22:05:23] ali_g: Ping timeout: 256 seconds
[23:55:33] ali_g: has joined #RubyOnRails

2018-01-16

[02:00:45] ali_g: has joined #RubyOnRails
[02:28:29] ali_g: Quit: Leaving.
[02:42:20] ali_g: has joined #RubyOnRails
[03:12:06] ali_g: Hello all! for some reason i'm no able to pass a variable from controller to the view. I get "undefined method `each' for nil:NilClass" https://gist.github.com/ponentesincausa/a6d8c1dd9956ae52664411f9bb0be8e6
[03:54:50] ali_g: fryguy the scope of completed tasks
[03:56:34] ali_g: @completed on that view is set to nil. But is I go @projects.tasks.completed i get an array of completed objects
[03:57:04] ali_g: so i tired @completed = @projects.tasks.completed on the controller to no avail
[03:57:20] ali_g: or @tasks.completed
[03:57:38] ali_g: however if I go @tasks.completed directly in the view it does fine
[03:58:53] ali_g: get the array in the view via the @completed variable to loop through
[03:59:04] ali_g: is it a wrong approach? asking for a friend
[04:12:06] ali_g: sort. put them at the end of the list
[04:45:32] ali_g: Quit: Leaving.
[04:53:08] ali_g: has joined #RubyOnRails
[05:44:24] ali_g: I found it it was because I was rendering the index template as if it was a partial
[06:26:55] ali_g: Quit: Leaving.

2018-01-15

[06:01:37] ali_g: has joined #RubyOnRails
[06:04:36] ali_g: what kind of trouble? what i've done before is create a model for each "sub-data" and just populate them one after the other
[06:05:19] ali_g: take a look at this, it's just a ruby file doing exactly that: https://github.com/ponentesincausa/melp-app/blob/master/read.rb
[06:14:09] ali_g: hello all! I'm having some trouble passing instance variables from controller to view. I created a scope and it works, but not if I define it as a variable within the controller. Here's the gist: https://gist.github.com/ponentesincausa/a6d8c1dd9956ae52664411f9bb0be8e6
[06:14:27] ali_g: what could it be?
[06:18:25] ali_g: havenwood @completed
[06:18:30] ali_g: has joined #ruby
[06:19:15] ali_g: :D i didn't know a #ruby channel existed. Thanks
[06:19:48] ali_g: yes its the index action. I read you could declare other instance variables from a certain action, so I did it that way.
[06:53:02] ali_g: has joined #ruby
[16:35:39] ali_g: Quit: Connection closed for inactivity

2018-01-08

[04:56:11] ali_g: has joined #RubyOnRails
[05:12:37] ali_g: Hello all! Has anyone successfully enabled Edit/update functionality on a belongs_to model with a single _form partial? I have Project has_many :tasks and Task belongs_to :projects. I can create tasks but when clicking on edit, the new form is loaded. Here the gist: https://gist.github.com/ponentesincausa/02d4b5cba3a61c880d0d604056273529
[05:30:41] ali_g: brilliant. Didn't know you could use render like that. Looks much better but still throwing an error.:
[05:30:52] ali_g: https://www.irccloud.com/pastebin/5Z3WcYLo/
[05:32:02] ali_g: uh nevermind
[05:32:28] ali_g: I did task: @task before and had an error but now its fine somehow :)
[05:32:34] ali_g: thanks Radar!
[09:57:37] ali_g: Quit: Connection closed for inactivity

2017-12-15

[00:02:28] ali_g: Ping timeout: 240 seconds

2017-12-14

[22:02:04] ali_g: has joined #RubyOnRails

2017-11-18

[06:11:12] ali_g: Quit: Connection closed for inactivity

2017-11-17

[23:44:09] ali_g: has joined #RubyOnRails

2017-11-13

[05:28:42] ali_g: ali [11:17 PM]
[05:28:43] ali_g: puts x['name']
[05:28:43] ali_g: a.each do |x|
[05:28:43] ali_g: i'll get the proper value. But if I do:
[05:28:43] ali_g: a = a[0]['name']
[05:28:43] ali_g: hi everyone! I'm having a hard time iterating a parsed json. If I do
[05:28:44] ali_g: i'll just get the whole array.
[05:28:45] ali_g: anybody knows why would that be?
[05:28:45] ali_g: puts a[x]['name'] returns an error
[05:35:10] ali_g: Thanks Radar, and I'm sorry. This is a plain ruby file.
[05:45:18] ali_g: sharing gist, thanks https://gist.github.com/ponentesincausa/8115dc5c9e2643de48bdc0b2a7213c19
[05:47:11] ali_g: a = ApiRead.new]
[05:47:17] ali_g: sorry wait
[05:47:29] ali_g: a = ApiRead.new
[05:51:40] ali_g: This is how https://www.irccloud.com/pastebin/PgmXBZoN/
[05:52:17] ali_g: The on irb I try this https://www.irccloud.com/pastebin/0lvWJKwB/
[06:00:27] ali_g: hey that looks much cleaner! and I see I was missing the attr_reader
[06:02:16] ali_g: so I'm running it like this reader = ApiRead.new(http://theurl) and it seems it runs up until line 10 which is the parsing I get 10:in `[]': no implicit conversion of String into Integer (TypeError)
[06:02:46] ali_g: so perhaps it's the format it parses to?
[06:04:03] ali_g: thanks for the correction btw it makes more sense to structure it that way
[06:18:40] ali_g: Ok I've got it 😁 https://stackoverflow.com/a/19549575
[11:37:52] ali_g: Quit: Connection closed for inactivity

2017-11-12

[07:07:31] ali_g: so I know this is a Rails channel but anyone familiar with sinatra?
[12:47:20] ali_g: Quit: Connection closed for inactivity
[21:48:56] ali_g: has joined #RubyOnRails

2017-11-11

[07:25:28] ali_g: has joined #RubyOnRails
[07:29:12] ali_g: Hi there. Has anyone consumed an API, which is actually a json served as an octect-stream application type?
[13:04:17] ali_g: Quit: Connection closed for inactivity
[20:40:47] ali_g: has joined #RubyOnRails

2017-09-28

[06:53:10] ali_g: has joined #RubyOnRails
[06:55:20] ali_g: I had a question but I solved it before posting, maybe it'll be useful to somebody. If you want to use ruby values inside an HTML attribute you can do so even when your editor doesn't change the text color (green text) take a look:
[06:55:37] ali_g: https://usercontent.irccloud-cdn.com/file/deD9hLJi/it%20works
[06:55:46] ali_g: love you rails
[07:55:57] ali_g: has anybody noticed rails includes an invisible 4px margin on the html? does anybody know how to get rid of it overall
[14:33:23] ali_g: Quit: Connection closed for inactivity

2017-09-13

[02:08:59] ali_g: has joined #RubyOnRails
[02:09:04] ali_g: For some reason my loop isn't looping how I need. I'm retrieving instances that have 2 active record relations in it. I need to loop through the years column to get all relations from the first year, then all relation from the second year... (code as follows)
[02:09:11] ali_g: https://www.irccloud.com/pastebin/rZEPgCBn/
[02:09:48] ali_g: (model fictional to exemplify)
[02:11:15] ali_g: (hi :) ) pretty sure i'm missing something 🤔
[02:41:18] ali_g: you know what? I simply needed a server restart
[02:41:59] ali_g: not sure why everything else was updating, but thanks anyhow :)
[10:11:24] ali_g: Quit: Connection closed for inactivity

2017-09-08

[07:17:50] ali_g: you get to see a nice matrix like business on your console while rails does it's thing
[07:17:50] ali_g: Model.all.collect { |e| e.update_attribute(:year, e.column_with_timestamp.year) }
[07:17:50] ali_g: just in case anyone is in need of a silly tip. I needed to extract the year from a time-stamp for each row in a table and updated a newly created year column. I know these kind of things are better done directly with sql but for a couple of reasons I ended up doing it in the rails console. This is what I used:
[10:06:41] ali_g: Quit: Connection closed for inactivity

2017-09-07

[20:50:57] ali_g: has joined #RubyOnRails
[20:58:32] ali_g: hello all... How can I use a form from another controller and model (called search/searches), on my Welcome controller index.html.erb file?
[20:59:35] ali_g: tried using the same code for the form but it doesn't render, no issues shown. Then I realized I must link my Welcome controller to the other controller somehow
[21:00:31] ali_g: https://www.irccloud.com/pastebin/34wfAYNn/this%20is%20the%20form
[21:01:05] ali_g: https://www.irccloud.com/pastebin/wC9zxlz5/welcome%20controller
[21:10:00] ali_g: no errors, the page loads all elements but the form is missing in the html 🤔
[21:10:15] ali_g: no errors on the server or the browser. No isea why.
[21:19:47] ali_g: hey you are right! Thanks tcopeland, this is one of those facepalm moments hahaha

2017-08-03

[15:24:18] ali_g: has joined #RubyOnRails
[17:45:08] ali_g: Ping timeout: 260 seconds

2017-07-31

[00:32:20] ali_g: hi there! so if I'm querying a table with Model.uniq.pluck(:user_id) as it has several entries per user, and I want to retrieve several of the columns of that table per user_id (so let's say I want retrieve the corresponding :first_name and :last_name for each :user_id but not the rest of the columns ) what would be a good way to do it?
[00:33:32] ali_g: I'm guessing if it Model.uniq.pluck(:user_id, :first_name, :last_name and the user has 2 rows with his id, but made a data entry mistake on his :first_name I'll get 2 of those, but I only need to get one
[00:53:14] ali_g: on :user_id (users can add several rows of data)
[00:54:19] ali_g: really trying to do an equivalent of excel's vlookup where I give the code a :user_id and get the values of other columns
[00:56:04] ali_g: havenwood: thanks! that answers my question :) need to practice proper chaining
[07:37:56] ali_g: Quit: Connection closed for inactivity

2017-07-24

[03:54:55] ali_g: has joined #RubyOnRails
[04:49:05] ali_g: Hi there. I have a model that has a datetime column. I need to extract a list of the years only?- I can extract the year from the datetime column for a single instance ie. @modelname = modelname.last.column_with_datetime.year however @modelname = modelname.all.column_with_datetime.year i get undefined method 'column_with_datetime' for #<Model
[05:19:28] ali_g: muzik, I got the answer, Model.all returns an array so Model.all.collect {|e| e.created_at.year} did the job :)
[15:23:59] ali_g: hi there! if I have a table with a column datetime and want to extract the year from it and put it to a new column, how do I go about doing it? so far I can extract the year by Model.all.collect { |e| e.column.year } and i get an array. How can I take that array and make the save relation of object per row in a column?
[16:17:23] ali_g: Thanks!, jnillo, I did it with Model.all.collect { |e| e.update_attribute(:year, e.column.year) } (note change of syntax)
[17:21:35] ali_g: https://gist.github.com/ponentesincausa/8fc8fe0cfed74e7779ffc6e08d62e99a
[17:21:35] ali_g: Here is my gist:
[17:21:35] ali_g: How can I reject empty search :params from the controller? If I submit an empty search form the query goes SELECT "fiscals".* FROM "fiscals" WHERE (nombre LIKE '%%')
[17:49:36] ali_g: tbuehlmann_: thanks I passed it to the model:
[17:49:44] ali_g: https://www.irccloud.com/pastebin/oHUwW7w0/