#RubyOnRails - 09 August 2015
« Back 1 day Forward 1 day »
[00:17:50] nofxx: m0r0n, controllers don't need to be pluralized, it what makes sense: foos_controller will have index/show foo_controller index will be it's show
[00:18:32] nofxx: hehe, guess didn't make myself very clear, but got it? many -> [index, show] one -> [index] (but it's kind a show)
[00:19:37] nofxx: m0r0n, if what confuses you is models (singular) again common sense: you're defining 1 of them
[00:32:41] aaronds: Hi. I've got a rails-specific issue here I'm wondering if someone could help me with. I'm trying to write a test for my controller, specifically the update action of my resource. The action works great in the browser, I just can't get a test to pass. I've documented my issue more extensively here: git.io/v3JDI but in essence I can't get 'put' to behave as I need to. It keeps throwing "No route matches" errors
[00:42:39] nofxx: aaronds, routes is just resource :lesson_types ? post it too, and where are you creating the lesson_type?
[00:47:32] aaronds: nofxx: Updated, yeah its a resource. The type is record as a fixture, so the record exists, if that's what you meant?
[00:57:16] aaronds: nofxx: don't think so... The error indicates that the base route is correct judging by the fact it's requesting an id
[00:57:58] aaronds: nofxx: maybe I should have specified this is in Coach::LessonTypesControllerTest ?
[03:31:55] zoidfarb: How do a create a table with a boolean column that defaults to false and can't be nil? Like "t.boolean :approved ... "
[05:50:45] iateadonut: i've just put my RoR application on a development server (rather than my localhost). after i deleted all entries in database.yml and put one for postgresql, the logs indicate that it is still trying to connect to sqlite. how do i change this?
[06:11:09] iateadonut: is there something i have to do to restart the application, as you have to when in irb?
[06:11:26] rhizome: now check Gemfile.lock for sqlite, maybe something's depending on it or it's hanging around for some reason.
[06:11:55] rhizome: well yeah, if you change the db gem you're going to have to restart the app at least then
[06:19:02] rhizome: you stop/start, or touch tmp/restart.txt if you're using passenger, or whatever is specific to your application server
[06:33:14] iateadonut: one thing i'm wondering, i didn't have 'pg' in my gemfile on my localhost, so why did it work?
[11:53:37] MikeMikail: Hi, anyone able to point me in right direction on getting this query count by grouped by number of hours in difference between these two DateTimes? OrderItem.joins(:order).group('orders.startdate - order_items.updated_at').count(:id)
[12:55:58] ethicalhack3r: Hi, I was wondering if anyone could help me with a RABL template. I need to move an attribute (fixed_in) from a child node (plugin_vulnerabilities), which is an association, to the parent node (vulnerabilities) - https://gist.github.com/ethicalhack3r/765863ebbe4316dc71ac
[12:56:27] MikeMikail: Hi, anyone able to point me in right direction on getting this query count by grouped by number of hours in difference between these two DateTimes? OrderItem.joins(:order).group('orders.startdate - order_items.updated_at').count(:id). Is it possible to do in a single line like this?
[13:10:18] ethicalhack3r: Found a solution to my question and added to the gist https://gist.github.com/ethicalhack3r/765863ebbe4316dc71ac
[14:51:00] dionysus69: how do I incorporate bootstrap into ruby app? should I just drop all the required css files into the app/css folder and they are integrated into pipeline automatically?
[15:25:38] dionysus69: should i totally get rid of rails-sass gem if i am installing bootstrap-sass?
[15:35:53] dionysus69: dunno it came with the template project that got downloaded from heroku (i think, it was a long time ago)
[15:36:33] dionysus69: also now since I installed boostrap-sass gem, do I rename application.css file to application.scss or to application.sass?
[15:37:15] dionysus69: i completely removed rails-sass gem btw it wasnt compatible with bootstrap-sass gem since they have different dependencies
[15:40:18] elaptics: dionysus69: oh actually, yes, it needs to be renamed to scss because it needs the @imports
[16:49:15] axilaris: hi, is there a shorthand for returning specific row ? for example User.first returns first. if i want to return id 24 how do i do that. is there a shorthand for this ?
[17:01:17] relix: Hey guys, is running multiple "rake db:migrate" unsafe? i.e. is there a chance the database ends up in an unwanted state?
[17:01:34] relix: multiple rake db:migrate at the same time, from different servers to the same db server
[17:04:18] relix: well I'd like to package up the rails app in a docker container, so that users can easily "upgrade" to the latest version just by running the latest container
[17:04:41] relix: using the passenger docker container, I can run a script when the container is run
[17:04:58] relix: I guess I could use some kind of mutex using the database to make sure "rake db:migrate" is only run once
[17:05:16] relix: (see they might start multiple containers at the same time, so in that case just running "rake db:migrate" at start is uncouth)
[17:05:51] elaptics: I'm not particularly familiar with docker - but how do you determine which is serving the DB?
[17:06:40] relix: the DB does not necessarily have to run in a container, but the usual way is to pass in an ENV variable to the application, which defines where the DB is located - in this case I"m using the rails default DATABASE_URL
[17:14:38] axilaris: hi, can someone help answer this. trying to figure out how to do dependent destroy for a relationship http://stackoverflow.com/questions/31906724/how-to-do-ruby-on-rails-relationship-dependent-destroy
[18:03:15] aaronds: Hi. Does anyone know how to stop RoutingError from being thrown when running test? It seems reasonable to want to check for 404's (e.g when a record cannot be found), but by default the error is thrown, preventing tests from passing.
[18:06:39] elaptics: aaronds: what do your tests look like? And what specifically is raising the routing error?
[18:09:13] aaronds: elaptics: http://git.io/v3LI3 very simple test. The controller works great in the browser.
[18:39:55] djbell: any routing experts online? Have a question: how can I have two different to_param for a model. I want /admin/order/:id and /api/order/:external_ref_id
[18:40:18] djbell: I tried overwriting api_orders_path in ApplicationHelper, but that didn't take...
[18:40:55] sha1sum: Hey all... I definitely have passenger concurrency misconfigured because every few days my server just drops off and won't even acknowledge connections. When looking in New Relic, there's a huge GC spike, which is when the server stops responding: http://imagebin.ca/v/2BZeDh4fVYh8
[18:41:32] djbell: and there's no way to specify different values for to_param depending on which route is requesting it afaik
[19:53:12] dcope: hey all, what's the best way to sanatize a string of curse words that can be two words (containing a space)?
[20:00:06] nerdsville: if I have an engine mounted inside another engine, how can I set the initializer config for that mounted engine?
[20:15:37] dymk: Is it possible to take an ActiveRecord::Relation that has had .select called on it (e.g. Upload.select(:id)) and re-select its columns?
[20:20:08] BaNzounet: Hey guys, I've this model https://gist.github.com/AlexGaspar/9bf14ef4f5dabcc0da95 how would you go with I18n.T(); to translate the symbole in text? Is the case in the gist the only solution?
[20:35:29] lalalaaa: Hi! Say I'm already running a Rails app (with Puma, Nginx and PostgreSQL) on my server -- exactly how much toll would it take on my system if I were to launch Discourse (http://github.com/discourse/discourse) from a Docker container?
[20:36:23] lalalaaa: Quite a lot right, considering I'd be emulating a whole new OS and doubling up on all my services?
[20:56:14] ellisTAA: if i want to create a new method in my controller called login, what is the rails way of creating that new route ??? so that i have users/login
[20:57:51] elaptics: EllisTAA: you need to specify it as either a member or collection route in that
[20:58:10] elaptics: EllisTAA: since it's not really a restful route, I'd just declare it in the routes
[21:05:32] ellisTAA: elaptics: what is the value of using as: ? I see that it changes the prefix in the routes from users_login to login, but how is the beneficial?
[21:09:01] elaptics: it's more useful when you have nested routes or repeated names - using as will simplify the name
[21:16:07] ellisTAA: i just created these two routes, https://gist.github.com/ellismarte/c28506303a23064030e9 and when i try to go to localhost:3000/signup it says ???no route matches [get] ???/signup???
[21:17:11] Radar: EllisTAA: Look at the routes you defined. Now to the error. NOW BACK TO THE ROUTES.
[21:17:21] helpa: EllisTAA: http://guides.rubyonrails.org/routing.html - Rails Routing From the Outside In - Rails Guide - by Mike Gunderloy
[21:18:00] helpa: What "didn't work"? Did your server not start? Did your computer explode? Did your webpage turn bright pink? Did your client not pay your bill on time? You may have to be more specific. A Gist (http://gist.github.com) of the code that doesn't work (and the error you are getting) will be helpful.
[21:18:22] elaptics: EllisTAA: pay closer attention to the route you defined and where you're visiting
[21:19:42] Radar: These routes need to be defined before resources :users otherwise the show action in resources :users will match those routes first.
[21:27:31] Radar: EllisTAA: Gist output of rake routes if you still need help. It'd help if I could highlight the lines :)
[21:29:32] elaptics: EllisTAA: don't think of :id as having to be a number - it's just an identifier effectively so you're just matching url strings. Given /users/:id then /users/10 and /users/signup both match the criteria. Once the routes have found a match they will not look further
[21:30:29] elaptics: EllisTAA: if you placed your users/signup route above resources :users then /users/signup will match that and route it whereas /users/10 would not match and will continue looking for routes - when it hits resources :users it'll match the show route criteria
[21:35:30] ellisTAA: i???m trying to create a new user, so the form goes to localhost:3000/users/create and the method is a post, and i???m getting a no route error ??? https://gist.github.com/ellismarte/c28506303a23064030e9 but the users/new route works just fine ???.
[21:37:02] ellisTAA: what about this: https://gist.github.com/ellismarte/c28506303a23064030e9#file-all-rb-L6
[21:52:06] renegadeandy: :) hey everyone. Can you help me figure this one out : https://gist.github.com/renegadeandy/19164505e5453eae80c7 -- trying to validate a non model persisted attribute but the validation seems to suggest the value of ticket_single_price is not being set to 0 correctly
[21:54:03] Radar: event parameters end here: https://gist.github.com/radar/c2bd6e9f1d9c1f098ca1#file-gistfile1-txt-L22
[21:54:11] Radar: ticket_single_price is here: https://gist.github.com/radar/c2bd6e9f1d9c1f098ca1#file-gistfile1-txt-L25
[21:54:21] Radar: So yes, the validations are working fine. You aren't submitting it through correctly.
[21:56:51] renegadeandy: Radar: https://gist.github.com/renegadeandy/5c26b2bb3c881250e66a that is the form element
[21:58:26] Radar: So show us 1) entire form 2) create action + event_params from controller 3) Event model
[21:59:56] renegadeandy: #1 it wasnt part of the event object. #2 it was not being permitted after i had renamed the html element
[22:13:25] ellisTAA: can anyone tell me why after i create a new user, the show page isn???t displaying the users alias? https://gist.github.com/ellismarte/6e7bcf8d87a5aa4fd0fb
[22:13:44] sprite--: Should I somehow refactor this test or does it look ok? It seems a bit repetitive. Also should I be testing each role for each action or if the entire Admin namespace requires a certain role is there a better way to test that? https://gist.github.com/sprite2005/994131ae2f3c4e0101eb
[22:15:47] ellisTAA: radar: whoa ur right. but why would the alias be nil if i???m sening over stuff in the form. am i not sending data over the form?
[22:16:09] Radar: EllisTAA: show us 1) entire form 2) create action + user_params from controller 4) User model
[22:34:42] ellisTAA: so if i want to hit my user controller and the login action, would i write url: user_path(login)
[22:59:01] stoodfarback: Is there a common thing for giving users the ability to cancel background tasks they started? And maybe report progress to the user. Basically, starting a background job is pretty straightforward, is there anything that takes it further? Or is this a roll-your-own type thing?
[23:04:36] stoodfarback: Radar: Kay, thanks. Any rec for abstracting away the communication between worker, server, and client?
[23:05:17] zoidfarb: Hello, I'm trying to figure out how to get a 'rails console' on a system managed by ansible with rbenv to set the ruby version. I keep getting an error like this: $ ./bin/rails console
[23:05:18] zoidfarb: /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- bundler/setup (LoadError)
[23:06:26] Radar: stoodfarback: Maybe split the job up into multiple jobs and then log that progress in the DB somewhere?
[23:08:06] zoidfarb: Radar: The server is up and running, so it is configured with the right things somewhere, just not in my own ssh console, apparently
[23:11:43] zoidfarb: Radar: Thanks! The rbenv command line tool is available in my shell now. Is there anything else I need?
[23:12:59] zoidfarb: Has the rails community reached a consensus on rbenv vs rvm? Or is that still flamewar bait?
[23:13:51] stoodfarback: Radar: OK, thanks for your time. This kind of stuff is pretty interesting to make anyway, so off I go.
[23:43:52] ellisTAA: i have a users controller, and users can register, login, and logout, but if someone tries to login with a username that doesn???t exist i get sent to locahost:3000/users/login and it says ???no data received err_empty_response??? anyone know why?
[23:50:29] helpa: Show rather than tell. Explaining your problem with code, stacktraces or errors is always preferred to explaining it with just text. Show us what's happening, rather than telling us.
[23:55:30] ellisTAA: so when it try to login as someone who doesn???t exist, i get a blank page with a chrome browser error that says ???no data received err_empty_response???