#RubyOnRails - 15 November 2015
« Back 1 day Forward 1 day »
[00:00:50] matthewd: Can you add a blob column, then UPDATE SET myblob = BINARY mytextthatactuallycontainsbinarydata ?
[00:05:14] mwlang: just saw something really odd. Set up a Rails 4.2 + Passenger + Nginx on HTTPS. Hit the root page of the Rails app just fine, but couldn???t hit any of the other routes. Got 404 and nothing was showing up in the production.log file to even indicate the request was passed from nginx to rails. Browser refresh, nginx restarts, etc. did not change anything. Then I stopped nginx, refreshed browser and got connection failed. Then I start
[00:12:54] techandy1: I am following this guide http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you// but when I get to compiling ossl_ssl.c this shits itself?
[00:15:45] jhass: techandy1: please still confirm the real error, but my bet so far is that ruby-install -p wget https://github.com/ruby/ruby/commit/801e1fe46d83c856844ba18ae4751478c59af0d1.diff ruby 2.2.3 will fix it
[00:17:23] dmarr: matthewd: when I try to update the BLOB field -> [UPDATE - 0 row(s), 0.003 secs] [Error Code: 1406, SQL State: 22001] Data truncation: Data too long for column 'pic' at row 1
[00:17:28] techandy1: I am following http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you// guide. I haven't had issues with it before today. But when I run ruby-install ruby 2.2.3 it compiles until it goes to "compiling ossl_ssl.c ?
[00:18:10] jhass: techandy1: why are you repeating your question with open follow ups and things to try pending?
[00:18:29] techandy1: ossl_ssl.c:141:27: error: 'SSLv3_method' undeclared here (not in a function) ......
[00:23:40] jhass: as said ruby-install -p https://github.com/ruby/ruby/commit/801e1fe46d83c856844ba18ae4751478c59af0d1.diff ruby 2.2.3 should fix it
[00:24:15] Intii: Hi all! If I'm using the Apartment gem for multi-tenancy (which by default creates a new schema in PSQL for each tenant), what would be the best way to create a administration panel to oversee the whole app?
[00:28:26] jhass: Radar: might want to update your debian based distro guides with applying https://github.com/ruby/ruby/commit/801e1fe46d83c856844ba18ae4751478c59af0d1.diff as patch, since they started to disable sslv3 in the latest openssl package apparently
[00:41:04] matthewd: Intii: That seems rather anathema to such strictly separated multi-tenancy, to me
[00:47:03] matthewd: Intii: I don't know what forces pushed to towards Apartment to begin with... it's always seemed to me like something one would only consider (or even find / know exists) with some form of regulatory requirement
[00:47:29] Intii: I don't have to use Apartment at all. If there is an alternative, I'm willing to look into it
[00:58:06] jhass: as said ruby-install -p https://github.com/ruby/ruby/commit/801e1fe46d83c856844ba18ae4751478c59af0d1.diff ruby 2.2.3 should fix it
[01:35:58] beingjohnm: I need the user to be able to upload an image (associated with a record) and have it resized and then both the original and the resized version be uplaaded to S3. Seems like there are a lot of ways to do that but wanted to see if anybody had any pointers
[02:17:14] _3by8: new_resource_path(id) doesn't seem to work. That normal or am I missing something?
[02:19:40] _3by8: How can I pass a parameter? Isn't there some sort of a hash I can pass to link_to?
[02:22:28] FailBit: if you have a resource helper, _always_ use the hash syntax to add URL parameters
[02:23:01] FailBit: if you don't, you will get unexpected behavior and open up yourself to URL hijacking
[04:07:23] dmarr: why is the write operation not covered here http://ruby-doc.org/core-2.2.3/File.html
[04:17:53] hello29: if i have a rails app hosted on a linux server, and I run a native linux bash command from that rails app, will the command execute regardless of the end user's operating system?
[04:20:18] hello29: @failbit so if i am running xdotool or something the end user would need that on their computer in order for it to work?
[04:25:27] hello29: ive got it working for me, but im testing it on a computer that has xdotool installed
[04:28:02] FailBit: (you can't even assume the client OS will be able to do anything, for that matter)
[04:31:19] FailBit: you literally pose an impossible task. if you want to control the client events, write a desktop app.
[04:43:40] dopie: How can I have the user fill out a form than it posts to the controller and then it posts to a website url?
[05:21:25] wa_r_ch_i__ld1: Is there any way to trigger a key event for an end user on a hosted Rails app?
[05:45:28] Metalstar: Ruby on Rails app for file serving. The "Content-disposition" tag of the header becomes "ntent-disposition". Need help!
[05:46:50] Metalstar: Ruby on Rails app for file serving. The "Content-disposition" tag of the header becomes "ntent-disposition". Need help!
[05:48:08] Metalstar: Ruby on Rails app for file serving. The "Content-disposition" tag of the header becomes "ntent-disposition". Need help!
[05:50:47] Metalstar: Ruby on Rails app for file serving. The "Content-disposition" tag of the header becomes "ntent-disposition". Need help!
[06:01:32] Metalstar: It uploads the first file, the next file gives an error in tag_multipart_encoding
[06:01:48] Metalstar: Ex: ntent-Disposition: form-data; name="fileUpload"; filename="tmp1.txt" Content-Type: text/plain Content-Transfer-Encoding: binary
[08:04:58] chayon: How should I override the validation error message? for example: validates_presence_of :name, message: "Location Can't be blank."
[08:30:34] zvive: I'm setting up a migration that belongs to a student on student_id in the table, but which actually points at users.id --- would I just to t.references :student, index: true, than add_foreign_key :student, :users, column: user_id ?
[08:59:53] arup_r: I am using Kaminari gem. I set default per as 9 from initializers https://github.com/amatsuda/kaminari#general-configuration-options . But no data is being displayed in view. If I inspect @users.count it is saying `9`.
[09:33:35] zvive: this is more of a logic question.. but say you have users... and you have teachers, students, parents, and children that all are users.. I currently have a self-referential thing setup matching teachers/students, and parents/children - but wouldn't it be more 'dry' or make sense to just create a relationship with maybe a main_id sub_id type (parent, teacher) where the sub would then be a child or student depending on type?
[09:43:22] mices: error running `gem install debugger` https://gist.github.com/mices/6e63ae0bb07c9de34d43
[09:47:59] zvive: debugger is not compatible with Ruby 2.0 or greater...what version of ruby are you running?
[09:49:45] zvive: https://github.com/cldwalker/debugger -- you can replace with byebug it's only needed if you're using it for debugging in the code.. really. Are you upgrading an older app to rails 4/ruby2? Or creating a new rails app?
[09:51:10] mices: exactly, i had a problem with my app (devise reconfirmable option wasn't compatibile with my ruby 1.9.1) so i upgraded ruby
[10:02:11] gavit: anyone here familiar with word coordinates and such? I have a polygon in wgs84zone21N, and I would like to calculate length of vertices and the area, would a normal math calculation work, or do I have to consider some kind of skewed mapping since the world is no longer flat (stupid scientists!)
[10:11:03] dopie: with 4234355432|1852196545 how can I tell regular expression to check only if the right side of the | is correct?
[10:12:34] tbuehlmann: dopie, what's "correct"? and is splitting on '|' and taking the last match maybe enough?
[10:40:52] alhimik45: Hi, how to change column id type from integer to uuid and not break foreign key constraints?
[10:53:03] gavit: alhimik45: http://stackoverflow.com/questions/31861621/how-to-migrate-from-using-one-foreign-key-to-another-in-activerecord
[12:00:18] l1meon: Hello, have a question, how to better structure the controllers if for example I have a gamescontroller that have 3 different type of games(small,medium,large) and these types have just a few methods in common the rest logic is different. How to structure them to a more rails way?
[13:08:25] arup_r: l1meon: That is perfect structure. See this: https://github.com/plataformatec/devise/tree/master/app/controllers
[14:10:46] mices: i upgraded to ruby 2.2.1 but `rails` commands at the console fail with /usr/bin/env: ruby1.9.1: No such file or directory
[14:15:48] beingjohnm: does a model have to relate to a database table? I'm trying to build a timeline composed of events from other models so I don't need any databse backing up my Timeline model.
[14:19:43] matthewd: beingjohnm: An AR::Base does, but it's perfectly normal to have non-AR classes in app/models/
[15:04:48] FailBit: it doesn't explain what's not working, nor does it explain your circumstances well
[15:14:14] yottanami: I need to use an oauth2 API that is created by Grape and doorkeeper. Is there any gem as client?
[15:17:35] dtordable: FailBit: running the exec of bin/ directory dont run but calling rake from the shell makes an option
[15:24:33] FailBit: alternatively, you can find them in the supermarket at the end of the frozen foods section, by the ice cream
[15:40:01] s2013: trying to figure out if there is a way to achieve this with one query.. we have a leads table and we have an applicaiton table.. leads are assigned a salesperson so what i want to do is find all the applications and find the sales person that was assigned to the lead based on the emails.. process is someone submits a lead -> salesperson isassigned -> the lead becomes an application if they purchase
[15:45:57] vnk: anyone got minute to help me with understunding really small ruby code? 10 lines or so. I got pretty much everything expect one small part.
[15:51:34] vnk: but that is not problem, I dont understund one part of code. Which one? part where we make new language
[15:56:08] FailBit: /tmp/execpad-5ad87bc0b56d/source-5ad87bc0b56d:12:in `initialize': wrong number of arguments (2 for 0) (ArgumentError)
[15:58:12] vnk: I used codeacademy guys on start, now I saved that code in lol.rb, runed it from terminal and it doesnt work ohh :D
[15:58:50] vnk: so in ruby we make initiliazer for class buy making method that is called extactly initialize, correct?
[16:00:16] vnk: thanks a lot.. ehh, I cannot belive that I was this confused only bescause of shitty codeacademy comapiler
[16:38:01] guacjack: hello, just got a quick question, on here https://github.com/mackenziechild/blog/blob/master/app/views/posts/show.html.erb on ln 14, Im a bit mystified on how it manages to render multiple partials, there are one or more comments on a post, but how does Rails know to render the comment partial?
[16:41:00] guacjack: FailBit: its not my project, just something im trying to reproduce, thank you for the quick reply :D
[16:41:26] elaptics: guacjack: there's plenty of info in the docs here http://api.rubyonrails.org/classes/ActionView/PartialRenderer.html
[16:41:37] guacjack: Im quite a beginner, when you say "implicit" does that mean, it does it by itself without my "explicitly" having to tell it to?
[16:43:19] guacjack: I'm working as a junior developer at the minute mainly in Ruby but using Sinatra at work so thought I'd give Rails a go this weekend
[16:44:56] FailBit: (except for ActiveRecord which is a gigantic pile of shit, but enough said on that)
[17:38:52] beingjohnm: I'm using this (http://railscasts.com/episodes/219-active-model?language=en&view=asciicast) to create a model that doesn't save data in the database. However it seems I can't use the all method (Foo.all) without ActiveRecord::Base? Is that the case? Having trouble Googling this question.
[17:42:20] jhass: beingjohnm: yes, where would you expect active model to fetch the instances/data from?
[17:44:51] beingjohnm: jhass: I thought I could maybe add this to the model "include ActiveRecord::Scoping::Named::ClassMethods" to use the .all method but that is giving me a scope error.
[17:47:18] beingjohnm: In my mind (perhaps incorrectly) I don't see why a model would need to be tied to a database. I think a record could exist in memory just as well as on disk.
[17:50:21] jhass: beingjohnm: well, that's a condition that might fit you in your current situation, but is it useful as a generalization?
[17:50:42] jhass: what objective arguments are there for that behavior, not using your current problem as a base?
[17:51:55] beingjohnm: jhass: populating the model in memory is quicker than populating from disk I guess
[17:52:10] jhass: anyway, what active model does is providing common logic for defining value objects, classes that describe some data and consistency rules inside it, and may tie some business logic to it
[17:52:57] jhass: if you so will it's a more elaborate version of Ruby's standard library Struct class
[17:56:27] beingjohnm: I've got a series of events that come from other models so nothing needs to be saved to disk. I'm creating one record for each in my Timeline controller. Then I need to go to the Timeline index view and print them out.
[17:58:30] beingjohnm: jhass: that was my original thought but then lose some of the benefits of activerecord. Also, doesn't seem very Rails-y.
[18:20:43] dmarr: that is in my AttachmentsController#index and I have resources :attachments in routes.rb, yet the method doesn't seem to run when I hit that route
[18:23:10] mices: what file do i have to edit so i don't have to type `source ~/.rvm/scripts/rvm` every time i open a new shell
[18:33:24] jhass: File.open(.., encoding: "binary") or shorter, File.write(a.filename, a.filedata, encoding: "binary")
[18:41:50] matthewd: dmarr: Ah, right, sorry... I misread that as a reply to "you should use 'wb' mode for writing"
[18:53:39] tildes: any exemplary public rails projects one could look at, to learn good style and practices?
[19:02:43] tildes: dmarr: I'd be interested in anything out of the most obvious "rails 101" scope. good structure / set of tests, well organized assets, good overall design within mvc framework, nice interfaces / APIs... anything worth looking at :)
[19:07:06] tildes: dmarr: I've been looking at mhartl's railstutorial, which already has many useful things for me. I think variety is helpful however, so any recommendations are welcome
[19:12:42] Papierkorb: tildes: there are a bunch of big OSS rails projects out there, though I can't tell you if they have a "good code quality" or w/e.
[19:13:03] Papierkorb: tildes: Redmine (Bug tracker, project management tool) and Spree (Online shop) come to mind
[19:16:53] mirageglobe: sorry quick question. is there any quick ways to list current methods/controllers?
[19:17:28] Papierkorb: mirageglobe: what do you mean with 'methods/controllers'? Available paths / URLs ?
[19:18:29] mirageglobe: I was wondering that rails allows you to create/delete controllers etc.. does it have a "ls" function or something?
[19:19:00] Papierkorb: mirageglobe: well, there is always "$ ls app/controllers", or "$ bin/rake routes"
[19:19:37] hello9: what is the difference between changing a key_prefix and namespacing the connection in redis? (i have this in my redis_config hash, do i need something else to namespace for multi-tenancy)
[19:26:15] mirageglobe: @Papierkorb thanks for this. I thought theres a built in management tool to see whats there
[19:44:52] tildes: mirageglobe: to see whats there, you would look under app/controllers, then you might want to look into config/routes.rb. if there are controller tests, perhaps run them first with formatted output. of course readme's and documentation can be helpful too
[20:05:58] Papierkorb: I have the actions #like and #unlike in my ArticlesController. I bound DELETE /like to #unlike. What would you think be the most reasonable HTTP verb for the #like action, residing under the same path? PUT?
[20:07:49] tubbo: i would have a LikesController that is nested under the :articles resource, then you can just POST /article/1/likes and DELETE /article/1/likes/2
[20:08:15] tubbo: maybe it could be a singular resource so you don't have to specify an id in the route
[20:15:48] Papierkorb: tbuehlmann: too complicated by using an extra controller. the controller actions are three lines each. I think I could get it down to two. one, if I could omit the render nothing: true.
[20:29:58] mices: if i wanna link_to destroy_admin_session_path do i have to specify the method, DELETE
[20:37:36] tbuehlmann: talking about devise, the route differs a little from what `resources` gives you
[20:54:31] mices: with devise can i stil administrate a table under it's own namespace, meaning adminstrating the admins table
[21:10:17] raunicolae: has left #RubyOnRails: ("Once you know what it is you want to be true, instinct is a very useful device for enabling you to know that it is")
[21:37:25] broman: can someone please help me? I just generated the scaffold and the NEW action gives me "undefined method `chaves_index_path' for #<#<Class:0x0000000474a0f0>:0x000000047487f0>"... I'm using rails 3.2 .. any thoughts?
[21:48:42] broman: FailBit, this line is wrong: <%= form_for @chafe do |f| %>... rake routes brings me that route
[21:51:01] rhizome: ok. if chaves is plural and the scaffold is describing a model, it should be singular
[22:00:38] hnanon: Yeah, I have...but I thought cloning via git would be faster and simpler at this point.
[22:02:06] broman: I'm trying to build an application with login (devise) and i need to implement roles... but i need to create these roles dynamically giving it a name and the permissions it can execute... i was trying to use Cancan... but is there any other kind of alternative to better accomplish that I'm searching for?
[22:07:04] Oog: https://gist.github.com/anonymous/f46c3f44bebfcdd18ec2 - #<ActiveRecord::AssociationTypeMismatch: CreditCard(#70246936046640) expected, got CreditCard(#70246833160000) ideas...?
[23:11:40] davidmst: Hey everyone, I'm currently trying to implement API versioning in my rails project and I'd like to be able to route to namespaced controllers depending on the major version... this is fairly straightforward, *however* I'd also like to be able to route any requests for anything above the current version to a specific controller and anything below a specific version to another controller
[23:12:36] davidmst: But if I have nested resources, I'd like to be able to route everything to say, "FutureVersionController"
[23:13:44] davidmst: Is there any way to catch all valid routes without a scope and redirect them or have them use utilise a specific controller?
[23:15:06] davidmst: Presumably you mean something like... scope(...) do; resource :users, controller: blah; etc; end;
[23:16:01] private-butts: So I created a join table using rails generate create_join_table and now it's stuck and I can't remove it rails destroy didn't work
[23:20:16] davidmst: Have you manually gone into the db/migrations directory to delete the migration?
[23:32:08] StaticVoid: I've disabled a field on my form. It makes the background grey-ish, but it is not dark enough. I can't figure out what CSS class drives this. Using bootstrap ssas.
[23:33:33] davidmst: And in the "Styles" pane, it should have a breakdown of the classes applying to the element
[23:36:11] StaticVoid: davidmst: Thx - it confirms that it uses the 'field' class, but: I tried various things before, and found out that somehow it also uses the 'input' class
[23:37:17] StaticVoid: I hope that makes sense? Is it possible to have it use a custom 'input' css class?
[23:40:01] StaticVoid: matt_d: yes, there is one field that should be disabled/readOnly and that one I want to use a different css/format
[23:42:49] private-butts: Alright, I'm back, sorry about the link, I gave you the clone url by accident
[23:45:19] private-butts: I just want to know where to stop db:migrate from recreating my join tables
[23:49:15] private-butts: Hell, I have the whole project in a public repo, do you want that instead?
[23:50:55] private-butts: here's the migrations directly: https://github.com/fluteamahoot/PCSheets/tree/master/db/migrate
[23:51:28] davidmst: Which are the table(s) that are joined together when you don't want them to be?
[23:53:26] StaticVoid: Radar: That worked! As long as I specify it in the css file with a 'dot' : ".inputdisabled". Thx!
[23:59:21] davidmst: The good thing about trying to fix something, even if you're spending a lot of time, is you get debugging skills that are helpful in the future