#RubyOnRails - 05 October 2013
« Back 1 day Forward 1 day »
[00:02:03]
iwaffles:
Is anyone else getting an update stream prematurely closed connection error when setting response.headers["My-custom-header"] = 33 on nginx?
[00:19:06]
bradherman:
you will likely just need to define the routes manually???. match '/', to: 'users#index', via: :get???. match '/:id', to: 'users#show', via: :get
[00:19:17]
luckyruby:
How do I assign attributes without saving in rails 2.3? #assign_attributes is a private method in 2.3.x
[00:23:17]
bradherman:
yeah, doesn't matter??? including haml gem just lets the application understand wth a file with .haml is and how to compile it to html
[00:24:12]
sarmiena_:
has anyone got ckeditor 4.0.6 to work with image uploads? i'm getting errors like "undefined local variable or method `root_path' for" because it's trying to use my app's layout
[00:24:14]
bradherman:
makes some files cleaner, but a lot of things more ugly and harder to understand
[00:26:34]
bradherman:
if you want cleaner files, look at presenters and just general better view writing
[00:26:53]
bradherman:
i actually really like haml, but it's just not worth using??? the benefits aren't worth the drawbacks
[00:26:59]
sarmiena_:
bradherman: we've been using https://github.com/galetahub/ckeditor for rails 3. but since upgrade, getting errors as described above. seems like too blatant of an error to go unnoticed
[01:05:37]
iwaffles:
Anyone ever had that error with nginx/passenger/rails? Getting the update stream prematurely closed connection when setting response.headers = ...
[01:25:05]
henn1nk:
it seems that dalli store (memcached) doesn't work on production server, how can i test this
[01:28:12]
delinquentme:
so how can I automate the install of something like the passenger configuration script ... since when I run $ passenger-install-nginx-module it asks for prompts !!!!!!!!!!!!!!!!!!! how do automate something like this!?
[01:35:30]
Hates_:
delinquentme: take a look at something like this https://www.linode.com/stackscripts/view/?StackScriptID=163
[01:37:38]
Hates_:
delinquentme: there are some good ones in there that'll setup everything you could need
[01:38:53]
delinquentme:
or one of these things: source <ssinclude StackScriptID=44> # Enable Universe
[01:38:57]
Hates_:
delinquentme: no like line 10 in that one I linked to, it's including another one
[01:48:41]
boytoy:
Shouldn't this seeds file, because of find_or_create_by_username, not try to overwrite the user if he / she exists? https://gist.github.com/kakekake89/6835619
[01:48:44]
boytoy:
Ie. http://stackoverflow.com/questions/3476987/appending-to-rake-dbseed-in-rails-and-running-it-without-duplicating-data
[01:51:42]
crankharder:
boytoy: no idea, but I'd think a 'seeds' file would be executed once when the DB is empty... that's the point, right?
[01:53:24]
tpayne84:
I have a New Form that populates a collection_select with values from the DB??? Relations for instance New User Form will populate the possible companies that a user could belong to??? and possible groups??? Later I have a Record object that I want to filter the Populated Users Select based on the selected company??? I am sure this can be done??? but I have no idea how
[02:13:01]
rehat:
I am so lost, so I have two models that are HABTM to each other and I made a foreign table for them called forms_dealers. But when I try to create a Dealer model and try to destroy it I get an error message that dealers_forms table does not exist
[02:14:40]
rushed:
rehat: convention is that the models in a crossover a listed in alpha order & *d*ealers is before *f*orms
[02:15:02]
rushed:
rehat: so you can drop yours and create the expected, or pass yours in as an option explicitly if you don't want to follow convention
[02:20:35]
orolo:
i'm creating an object via ajax and i'd like to return the object params via JSON so i can update my DOM with that form data. i have a standard create method: https://gist.github.com/cernalpanic/046dbf69849a2ff1c639
[02:20:53]
orolo:
but when i log out 'data' in my ajax call, i get the DOM returned to me as a string.
[03:47:16]
orolo:
i have a modal form that i'm rendering to create objects via ajax. but how do use that same modal form to edit an existing object? i'm not sure how to pass the object id to that form.
[03:49:11]
orolo:
i know the id of the object i want to update on the javascript side. how do i pass that id to my <%= form_for @thisObject %>
[03:55:46]
rhizome:
orolo: use whatever instance variable you like, just set them up in #new and #edit as normal
[04:05:22]
orolo:
here's my q distilled: when i click a button on the dom, i use an ajax request to go to my method and return a JSON version of my object. in erb, how do i set that json object as a regular old rails @object?
[04:13:10]
orolo:
i can get it back as an object in my ajax success method; i'm trying to figure out how to pass it to an erb form_for.
[04:16:53]
sarmiena_:
probably a longshot, but does anyone know why rails 4 removed *args from ActiveSupport::Callbacks#run_callbacks? http://pastie.org/8379081
[04:20:02]
jhn:
orolo: yeah, so you can serialize it in your controller and store it in an instance variable, then it'll be available in the view.
[04:23:06]
orolo:
in an ajax success call back, data.myObj contains a JSON version of the object i want to pass to the form. how to i pass that javascript version back into rails?
[04:25:28]
jhn:
when the form is processed and it hits your controller, the values will be in the params hash.
[04:25:43]
orolo:
well, i'm trying to get it into a form_for @obj; rails is helping w/ dates and so it is breaking the date up into several sections; so i'm trying to get the actual obj.
[04:26:27]
orolo:
the form creates a month, day, year, minute second select inputs and so i'm trying to avoid reading those back in. but maybe i'll cut my losses and do that.
[04:30:51]
orolo:
hmm. yeah, i'll that; no, i think you are; i'm trying to share a form on one page for create and update and am getting confused.
[04:36:24]
thebay:
hi, anyone have the last release of Agile web development with Rails 4. released Oct 1th
[04:43:52]
xybre:
Okay, look I read the hacker manifesto, information wants to be free, I get it. You can still google it.
[04:49:11]
boytoy:
Would it be considered normal for ones asset precompilation to take 30+ minutes if one has 1 Intel Xeon processor with 512 MB RAM, some 64 KB of local JS and 384 KB of vendor JS?
[05:39:48]
Radar:
jhn: I'm going to be in DC at the end of this month. Maybe you can come up and say hi? :P
[05:58:23]
michael_mbp:
does this look ok to you? node.set[:databox][:db_root_password] = node.default[:storagebox][:db_root_password] if node.default[:storagebox][:db_root_password].present?
[06:27:55]
luckyruby:
For my project, on branch X I added some migrations a couple weeks ago. Just now I added a couple new migrations to my production branch (needed to add some indexes for a few slow queries). When I git checkout x; git merge production, I get a conflict in my db/schema.rb for obvious reasons. How do you guys handle this type of situation in your development workflow?
[07:20:34]
kara_sweets:
can you add a help view in terminal so when someone enters and adds -h it shows the help
[08:27:24]
n88:
how would i make sure that a search string coming in through params is a certain length
[08:30:47]
tbuehlmann:
n88, validate it yourself in a private controller methods or build up a Search class which has validations itself
[08:32:09]
n88:
tbuehlmann: do you see the problem in this: https://gist.github.com/n8fischer/cf140261ff657598e7b3
[08:34:08]
tbuehlmann:
yeah, and make sure params[:search] is set, because there's no size method for nil either
[08:36:58]
tbuehlmann:
as said, have a dedicated class for the search and validate that search against the length of the search term. OR check the length as you do and react accordingly
[08:44:55]
n88:
the search.html.erb is sending params[:search] to that controller... i'm parsing out the :search to isbn_query and then i want to let the user know if it wasn't 10 digits
[08:51:34]
boytoy:
Anybody know why it takes like 1 hour to precompile my assets on my VPS? It's a single Intel Xeon processor with 1024 MB RAM. My stylesheet is relatively small, I only got like 5 images and my local JS is 64 KB. My vendor JS is 384 KB.
[08:52:18]
tbuehlmann:
params.fetch(:search, '') means: return params[:search] if it is set, and if not, return ''
[08:54:15]
tbuehlmann:
in other words: the method call to redirect_to can't return in the calling method
[09:03:04]
tbuehlmann:
n88, redirect_to uses request.env["HTTP_REFERER"] for :back. and that's either nil or a full url, so you're safe using that
[09:34:45]
robertjpayne:
Is it bad practice to create associations/tear down associations in model hooks?
[10:39:15]
filp:
Hey guys, quick question if anyone has any idea - I'm pushing an app to heroku, but it's complaining about the devise secret key missing
[10:39:39]
filp:
I'm reading the key from an ENV variable, which is set through config:add, and have set initialize_on_precompile to false
[10:55:18]
coj:
from all i gather, turbolinks is turned on in Rails 4 by default, but why doesn't my new app seem to use it? it only seems to work if, for example, i do link_to with the remote: true option
[11:01:41]
n88:
if i'm returning an instance variable back to a user for them to verify/change attributes (in a form but i dont want them to be able to edit all the attributes) before persisting the data... should i just have hidden inputs for the attributes i don't want them to edit/see
[11:02:14]
n88:
or how would i make that instance variable 'live' across two separate controller requests
[11:35:45]
afrodiziak:
what method is used to remove a substring at specific index from a string and which page has the best api db to find this for ruby?
[11:41:20]
willbradley:
afrodiziak: i'm not sure, but https://www.google.com/search?q=ruby+remove+a+substring+at+specific+index+from+a+string and http://www.ruby-doc.org/core-1.9.3/String.html
[11:42:06]
svector:
why doesn't my page execute js( ie. doc.ready) when reached by clicking a link and does so when it is refreshed?
[12:35:29]
wuzzzzaah:
hi guys, if i have a db server on an aws ec2 instance store, what happens if i reboot it? do i retain the data on disk?
[12:39:15]
wuzzzzaah:
amazon page says "This will cause you to lose any data you have saved on the local instance store of the instance, and will change your internal IP (except when running in Amazon VPC)."
[12:39:44]
ktkaushik:
+ wuzzzzaah as i said, i really cannot guarantee. But restart is definitely in order
[12:55:07]
Stalkr_:
webdestroya: He, I accidentally bugged the app again. I realized version 3.2.14 will fix it, so must be some bug on 3.2.6 I assume
[13:34:51]
krz:
in AR, when one calls User. how does it know which table in the db it is associated with? if i were to implement the same fuctionality with a class and a different db solution. should I be using a class variable?
[13:44:20]
tbuehlmann:
krz, rails knows it by convention, see http://api.rubyonrails.org/classes/ActiveRecord/ModelSchema/ClassMethods.html#method-i-table_name
[14:17:39]
svector:
Hello, can you suggest me the simplest Bootstrap gem. I don't write less or sass
[14:23:41]
roar_:
hello, I try to use devise's sign_in with rspec for testing but I'm getting this error: "undefined method `env' for nil:NilClass". as far as I can say it's because @request is nil. according to some google results @request is being set by rspec (after an http request?)
[14:24:28]
catom:
is 202 the appropriate http status code to return to a browser when a task has been submitted to a worker for processing?
[14:31:18]
roar_:
bastilian, ah, ok. thanks. so there is no way to use devise's sign_in with capybara?
[14:33:32]
bastilian:
roar_: maybe read this: http://schneems.com/post/15948562424/speed-up-capybara-tests-with-devise
[14:41:03]
dsferreira:
Hi there. I'm justing wondering what would be the best way to log a rake db:seed process with capistrano. Is it ok just to send verbosity to STDOUT? Will it be displayed by capistrano? Any ideas?
[14:59:07]
svector:
I keep getting couldn't find file 'twitter/bootstrap' after installing bootstrap-saas-rails. I'm using rails 4
[15:07:08]
AntelopeSalad:
has anyone gotten "addthis" to work with turbolinks in such a way that no js errors occur in the end?
[15:11:21]
someish:
Why am I getting a undefined method 'int' error here: https://gist.github.com/saturday/e31bb8d62593502a51c9
[15:42:23]
AntelopeSalad:
is there a DRY way to introduce a new rails env (staging) and have it do exactly what the production env does?
[15:44:12]
AntelopeSalad:
is it as simple as making a new staging.rb file in the envs folder and setting the env up before i load rails?
[15:46:03]
AntelopeSalad:
in this case i just wanted to use disqus, google analytics, and addthis with the final compiled/production assets but not use the real shortname/tracking/etc.
[15:48:59]
workmad3:
AntelopeSalad: the even easier way to introduce a staging.rb and have it do the same as production.rb is to stick 'require_relative "production.rb" ' at the top of the file
[15:49:14]
workmad3:
AntelopeSalad: and then do the configure block and override anything you need changing
[15:50:35]
workmad3:
I don't normally like the way that 'require_relative' connects two files positionally to each other, but considering that environment files are always in the same place it's ok there :)
[15:51:21]
AntelopeSalad:
i'm only concerned about littering my views with Rails.env checks all over, this seems really messy
[15:53:59]
workmad3:
AntelopeSalad: apart from in some config loading, you shouldn't usually need to check which env you're in
[15:54:18]
workmad3:
AntelopeSalad: no, so you push in config data from a yml file or env vars that you set
[16:14:30]
tpayne84:
Can anyone point me toward the relevant documentation for this issue: Record: belongs_to :user / has_one :course / has_one :client, through: :user / has_one :group, through: :user ??? on the index page for the Report I would like to have a form with selects for client, group, and user (the form, I have already made) ??? but I do not know how to make the form post action return a filtered index page. (I have the scop
[16:27:12]
svector:
anyone fixed the "Don't know how to build task 'convert'" problem when trying to upgrade to bootstrap 3 in bootstrap-less?
[16:52:00]
henn1nk:
universa1: i am using now dalli for caching this big sql query???but in production it seams this doesn't work right, cause the perfomance is still slow :(
[16:56:58]
AntelopeSalad:
workmad3: oh, what do you use for config variable management? i read about 10 diff blog posts but couldn't get anything to work
[16:59:03]
workmad3:
AntelopeSalad: sometimes configatron, sometimes I'll just add to the Rails config object after loading from a YAML file, sometimes I'll load from environment variables... really depends on how I'm deploying the project and how much config there is to manage
[16:59:47]
AntelopeSalad:
then i added them to each env.rb file specifically but they were always empty
[17:01:40]
AntelopeSalad:
workmad3: i tried using this gem https://github.com/dhh/custom_configuration
[17:02:30]
AntelopeSalad:
then i also tried implementing this from a railscast , https://github.com/railscasts/085-yaml-configuration-revised/blob/master/blog-after/config/application.rb#L12 , it always error'd out saying it didn't know what "development" was
[17:02:54]
AntelopeSalad:
then i just tried adding config.foo = "bar" to each env file and accessing it with ENV[] but it was empty
[17:04:19]
workmad3:
AntelopeSalad: where on earth did you get the idea that adding stuff to the rails config object would affect the environment variables?
[17:05:18]
workmad3:
AntelopeSalad: right... for accessing things you've set as *environment variables*
[17:05:42]
AntelopeSalad:
i tried accessing it with Rails.env.foobar too, then it says method not found
[17:05:58]
workmad3:
AntelopeSalad: right, because again *nothing* would tell you that was the way to do things
[17:06:14]
workmad3:
AntelopeSalad: whereas you've already linked to something that tells you *exactly* how you should access things
[17:08:40]
AntelopeSalad:
ok, in my development.rb file i have: config.x.google_track_page_view = false
[17:09:07]
AntelopeSalad:
in the view file using it i put: Rails.configuration.x.google_track_page_view
[17:10:09]
AntelopeSalad:
i have a few other keys too which are strings but they are also {} when i try to read them
[17:11:15]
workmad3:
right, well looking at the code (and then looking at the example) the idea is that you should have a namespace and then the config
[17:12:59]
iwaffles:
Is anyone else getting an update stream prematurely closed connection error when setting response.headers["My-custom-header"] = 33 on nginx? Not really sure if it's a simple fix or not.
[17:13:42]
workmad3:
AntelopeSalad: the code (which is a massive 10 lines) makes it pretty clear how
[17:14:31]
AntelopeSalad:
it seems weird to me that he would demand a namespace because the code example made it look like namespaces were something optional for organizational purposes
[17:15:17]
workmad3:
AntelopeSalad: right... so you try something, then when it doesn't act like you expect you then went and read the code, right?
[17:15:59]
workmad3:
AntelopeSalad: or did you assume it just didn't work and just started doing random things that you had no reason to expect would work at all?
[17:16:06]
AntelopeSalad:
workmad3: i didn't know what to make of it, i see nothing there that make it require a second namespace
[17:17:06]
workmad3:
AntelopeSalad: well, for starters config.x is a CustomConfiguration that adds new config keys through a method_missing
[17:17:38]
workmad3:
AntelopeSalad: and if you do 'config.x.foo_bar = "buzz" ' then the config key that gets set (to an OrderedOptions object) is foo_bar=
[17:17:59]
workmad3:
AntelopeSalad: or, in other words, the code that sets the config key in that class *ignores* any arguments you pass in
[17:19:31]
AntelopeSalad:
how does that say "listen, you need to double namespace your keys or it will break by not throwing an error but instead giving you empty values"
[17:20:17]
workmad3:
AntelopeSalad: it says that by *reading* the code and following through what it deos
[17:20:52]
tpayne84:
I have a form that is passing some params: "user_id"=>{"0"=>"248"} ???that is what is being passed and the value of the select that holds user_is is 248 in this instance, I do not know where the 0 is coming from. More to the point, how do I pull out the 248 as the value to do stuff with. I am trying to extract it like this: user_id: params[:user_id] ??? but that is giving me a range 0..248 anyone know what I am do
[17:22:05]
workmad3:
AntelopeSalad: or rather, you should read the 'deprecation notice' *very* carefully
[17:22:14]
workmad3:
AntelopeSalad: it says something completely different if you do more than skim it :P
[17:22:20]
AntelopeSalad:
that is the link given (#1 hit) when i googled for "active record orderedoptions"
[17:23:20]
workmad3:
AntelopeSalad: first off, given the line 'ActiveSupport::OrderedOptions', why would you search for 'active record'?
[17:24:12]
workmad3:
AntelopeSalad: given the 11 lines in that file, figure out what exactly is happening
[17:25:49]
workmad3:
AntelopeSalad: and as I said... read what you thought was a deprecation notice *really* carefully
[17:26:16]
AntelopeSalad:
i already got rid of that page because it was for activerecord not activesupport
[17:26:25]
AntelopeSalad:
the one i'm looking at now is http://api.rubyonrails.org/classes/ActiveSupport/OrderedOptions.html
[17:27:09]
workmad3:
AntelopeSalad: right, so now you know what that does, understand what that gem is doing ;)
[17:27:41]
AntelopeSalad:
it seems to be sugar so you don't have to deal with writing typical hash keys?
[17:28:27]
AntelopeSalad:
but with all that said i still have no idea why it requres 2 namespaces to function properly
[17:31:27]
workmad3:
AntelopeSalad: so config.x is a CustomConfiguration::Configuration instance... so what is config.x.something ?
[17:31:31]
relix:
hey guys, I have a javascript file that embeds a SWF file, however I want that SWF file passed from the asset pipeline - i.e. it has a fingerprint
[17:31:58]
relix:
what are my options to do this? I'm thinking of using Gon to pass the correct path on every request, and then read that Gon variable in the javascript file
[17:32:20]
AntelopeSalad:
i'm still trying to google what that configuration class is, not getting any hits
[17:34:12]
workmad3:
you had a file open that declared a class called 'CustomConfiguration::Configuration' and you thought that when an instance of this was created elsewhere that it was something *else*?
[17:34:31]
AntelopeSalad:
yes because i was looking at each file one at a time, i didn't have them side by side
[17:37:19]
workmad3:
AntelopeSalad: also consider what would end up in the @configurations hash for that call
[17:38:38]
workmad3:
AntelopeSalad: you'd end up with the key @configurations[:foo=] ||= ActiveSupport::OrderedOptions.new
[17:39:45]
AntelopeSalad:
this is a lot of code to fit in my head at once, i already forgot what that orderedoptions did
[17:43:21]
workmad3:
AntelopeSalad: the main thing is that you want to be setting your config on an ActiveSupport::OrderedOptions
[17:44:07]
workmad3:
AntelopeSalad: so you then need to set your config on that... so config.x.whatever.my_config = "foobar"
[17:44:44]
AntelopeSalad:
so the .x was just to separate it from the regular config.some = "value" stuff
[17:45:08]
workmad3:
the .x was a place to put an object that would create AS::OrderedOptions objects on-demand
[17:46:05]
AntelopeSalad:
btw if you wanted a set of config options to be the same for 3 envs but different for 1, would you drop the 3 identical versions in application.rb and overwrite it in production.rb?
[17:47:38]
workmad3:
AntelopeSalad: I'd probably create a config/something.yml file, and then add to the rails config option with 'config.something = YAML.load_file(Rails.root + "config/something.yml")[Rails.env]'
[17:48:04]
workmad3:
AntelopeSalad: and then in the yml file, you can have production:, development:, test:, etc settings
[17:49:49]
workmad3:
AntelopeSalad: if I was setting directly in the config/environments/*.rb files, I'd consider dhh's gem now I know about it
[17:50:28]
workmad3:
AntelopeSalad: but I probably wouldn't bother when loading from a yaml file, because I cba to recurse through the loaded hash and symbolize everything/turn it into OrderedOptions objects
[17:51:13]
relix:
however, I have a folder assets/swf, and it is not searched unless I add it to the config.asset_path array
[17:52:59]
AntelopeSalad:
workmad3: you said you couldn't be bothered to do everything that his gem is doing
[17:53:02]
relix:
workmad3 actually are you sure? because the rails guides does say only the images, javascripts and stylesheets dirs are searched by default in rails 3
[17:53:29]
workmad3:
AntelopeSalad: I said I couldn't be bothered to do something that is completely separate to what that gem provides
[17:54:10]
AntelopeSalad:
it seems clumsy to me that with the non-yaml approach you have to edit multiple files
[17:54:14]
workmad3:
relix: I've added lots and lots of app/assets subfolders in a rails 3.2 project and never had to add them to the asset_path searches ;)
[17:55:22]
relix:
workmad3 I'm using view_context.asset_path("swf/main.swf") (i'm sourcing it in the controller)
[17:57:31]
localhost3000:
hey guys - trying to debug a dynamic nested fields_for where the :child_index attribute is being ignored. any thoughts on likely cause? same link_to_add_fields helper is working just fine for other models.
[18:01:41]
AntelopeSalad:
workmad3: do you know of any easy fix so that you can put your config.x.foo.bar values in the application.rb rather than each env file?
[18:03:12]
localhost3000:
hmm interesting. ok. i had overridden the association method on the model and that bricked the :child_index function in the form...odd
[18:05:03]
rushed:
AntelopeSalad: if you look in application.rb you'll probably see several examples of setting config items
[18:05:59]
AntelopeSalad:
rushed: yeah, except in this case with dhh's gem the values do not get set
[18:07:19]
workmad3:
AntelopeSalad: have you tried it since you realised you were using the library wrong initially? :P
[18:11:23]
sarmiena_:
I'm working on an engine-based gem right now. seems the gem's own views don't have access to its custom helper methods. not sure where to start debugging
[18:16:21]
naquad:
could somebody point me to document describing new things in rails 4.0 and migration from 3.2?
[18:40:29]
banisterfiend:
if i already have a model called Role, can i still create a role scaffold?
[18:45:43]
coj:
i ran into that issue today, banisterfiend, and i ended up creating the controller and views manually
[18:46:26]
tbuehlmann:
banisterfiend, there should be a scaffold_controller generator. like, rails g scaffold_controller roles
[18:47:49]
coj:
is active_admin any good for creating a general management interface? i've installed rails_admin but i suspect it's not really meant to be customized or offered to all users
[18:54:19]
sarmiena_:
rhizome: poking around on the active_admin demo. seems wicked slow on a per-request basis. can't see the logs??? but you think there are some optimization concerns?
[18:54:50]
sarmiena_:
i'm assuming it's being hosted on a free heroku account, but once it's loaded up, it should be decently quick
[19:03:39]
banisterfiend:
does 'belongs_to' do anything other than just putting a method on the model to access the other one? so, if i have a join model, i could potentially leave off the 'belongs_to' ? (if i didn't care about accessing the parent model from the join model)
[19:06:51]
sarmiena_:
banisterfiend: yes. you can leave off relationship declarations in any model. they are just there for accessibility to the relationship from/through that specific model
[19:24:35]
sarmiena_:
banisterfiend: hah. you've helped me a few times in ruby channel. had claimed to be drunk
[19:46:09]
digitalcake:
I'm trying to work on the rolify gem and the CLI says its passing build but I'm getting failures on that same commit and branch. Has anyone else dealt with this type of issue before?
[20:07:02]
rushed:
sarmiena_: no, it's how you explicitly access helpers from an engine or main app from views which may or may not be overwritten (perhaps I misunderstood your question) :)
[20:12:25]
henn1nk:
why is searched the constraint Price? https://gist.github.com/henn1nk/6845514#file-gistfile1-txt-L1
[20:14:26]
henn1nk:
workmad3: i just created a controller manage_prices_controller.rb ??? but i didn't created a model price (because i don't want it) but rails seems to search the model?
[20:16:39]
metus_violarium:
Hello, people, do anybody know book or another material about testing (RSpec), and it's desirable to be free
[20:20:10]
metus_violarium:
about TDD in general. But I use RSpec - so it's more useful for me. I'm looking for "tips and tricks".
[20:20:38]
csaunders:
I personally like descriptive test names??? but whatever, I'm open to suggestions
[20:22:28]
workmad3:
csaunders: that said, the 'bad' examples are still bad... but the 'good' examples are also atrocious :)
[20:22:36]
metus_violarium:
Thank you. Sometimes it's too difficult to decide what I shoul test or not. In one project I had more test-code than work-code
[20:23:26]
workmad3:
metus_violarium: I have book suggestions for help on some of that, if you're interested :)
[20:23:35]
csaunders:
workmad3: gimmegimmegimmegimmegimmegimmegimmegimmegimmegimmegimmegimmegimmegimmegimme
[20:26:38]
csaunders:
Read through the first section of DSLs??? then figured I was done. The rest looked like reference
[20:27:11]
metus_violarium:
When I was starting, I read Michael Hartl. And he didn't use controller tests, do you?
[20:27:40]
yekta:
I'm setting up a new production environment, but my assets keep 404'ing, running nginx, unicorn with rails 4 and ruby 2 - I've set config.serve_static_assets = true, is there something else I need to do?
[20:28:19]
csaunders:
metus_violarium: normally yes. But I'm typically building out APIs / backend stuff, so controller tests are kinda necessary
[20:28:59]
csaunders:
if your controllers are effectively proxy calls to your AR methods, then maybe not?
[20:29:15]
csaunders:
but once you get to anything real (logged in users, ownership, etc) you probably need some controller tests
[20:29:27]
metus_violarium:
csaunders: I mean, that I saw 3 types of tests: unit-tests for models and other your own stuff, controllers tests and integration tests
[20:29:38]
sarmiena_:
can someone help me figure out why my block isn't returning expected results? http://hastebin.com/yewujivevi.vala
[20:30:14]
metus_violarium:
And integration tests, sometimes, is possible to use instead of contoller tests
[20:30:20]
csaunders:
though when I've run into some really messed up situations I've done integration tests that brought up some really interesting bugs
[20:30:41]
yekta:
My css and JS is loading but images and fonts that aren't loading on my production env, they are 404'ing. what might be wrong in this scenario?
[20:31:49]
csaunders:
think you might need to add something to nginx to point to your public directory
[20:32:23]
metus_violarium:
csaunders: thank you. Haven't you tried cucumer for unit-testing, have you?
[20:35:06]
metus_violarium:
And one more question: how do you deal in tests with internationalization?
[20:35:21]
yekta:
csaunders: hang on, I just realized that my code isn't using the config.assets.compile true change from my latest deploy???
[20:35:44]
csaunders:
metus_violarium: there's a way to do it, you effectively just verify that the correct internationalization key is used
[20:35:56]
workmad3:
csaunders: yeah, xUnit is similar to DSLs (and Refactoring), about 100 pages or so of narratives, the rest is a patterns catalog that's good to skim through and know what's there, and delve into on-demand
[20:37:10]
csaunders:
sarmiena_: long shot, but I *think* you don't need to take in &block as an argument if you are going to do block_given?
[20:38:53]
csaunders:
also, I think you could just do def speak(prefix=nil, &blk); puts "#{(blk ? blk.call : prefix)} bark bark"; end
[20:38:53]
metus_violarium:
csaunders: I have not worked with them to, but I use l18n for one language :) And in tests I just use l18n too - not "Submit", but l18n.t('buttons.submit') - is it normal. What do you think?
[20:39:30]
workmad3:
metus_violarium: tbh, I'm not sure what's best there... guess it depends on what aspects you want to test
[20:40:19]
metus_violarium:
workmad3: filling forms. check, that links send you in the right way and etc.
[20:40:27]
workmad3:
metus_violarium: I went for using I18n in my expectations mainly because it helped my reduce the fragility of the tests... but I mostly now make sure that certain page areas are present rather than exact text
[20:42:13]
workmad3:
metus_violarium: so for links, I'd do something like 'page.find("[data-role='site-home']").click' rather than 'click_link "Home" ' or 'click_link I18n.t(:home_link)'
[20:47:19]
metus_violarium:
workmad3: so, do you mean, that if you test functional part, you should use something sensible - not just text. But when do you test content (names and somebody else), it's better to use exact text for all languages?
[20:47:31]
csaunders:
rvm should also have a way of listing your installed rubies and which one is active
[20:47:36]
rushed:
delinquentme: ruby -v => ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0] also "rvm list"
[20:47:42]
henn1nk:
i don't understand, why my controller action is not found: https://gist.github.com/henn1nk/6845832#file-gistfile1-txt-L1
[20:49:31]
workmad3:
metus_violarium: at least not in a TDD style, and I wouldn't automate them much... tests for content are massively fiddly and brittle, or the end up in a situation where you ensure that something is there, but you don't test that it's what you really wanted
[20:50:30]
rushed:
henn1nk: quickly glancing at your routes I don't see manage/basic_articles/change_price defined??? what url did you request & which route do you think should be handling it
[20:50:38]
boytoy:
henn1nk: My asset precompilation takes about an hour on an Intel Xeon VPS with 1024 MB RAM. Is that normal?
[20:51:35]
csaunders:
boytoy: We have a very large batmanjs app at Shopify and it takes *maybe* 5 minutes
[20:51:51]
workmad3:
boytoy: the most extreme I've heard of was 45 minutes on a decent machine (6 hours on a low-powered AWS box) and that was megabytes of assets
[20:53:10]
sarmiena_:
i had a crap load of images that i wasn't using. so i removed them and brought it down to 25 minutes
[20:53:30]
boytoy:
workmad3: It's a http://transip.eu Blade VPS, that runs KVM virtualization on Linux to provide me with the OpenBSD operating system
[20:54:12]
rushed:
henn1nk: you're saying a matching destination exists so it should work, that doesn't follow
[20:54:16]
boytoy:
sarmiena_: Cool, well, I'm using this CSS sprite so I only really got one image :P
[20:54:50]
henn1nk:
rushed: get '/change/prices/basic_article/:id' => 'manage/basic_articles#change_price', as: 'change_prices_basic_article' is this a wrong syntax?
[20:55:09]
workmad3:
boytoy: I assume that your block devices are really files on the host OS rather than being direct hardware on partitions?
[20:56:02]
workmad3:
boytoy: it's certainly going to be contributing... potentially quite significantly
[20:56:07]
sarmiena_:
workmad3: i have similar setup as boytoy, but using proxmox/kvm with VirtIO on direct hardware partitions
[20:56:26]
henn1nk:
rushed: = form_tag change_prices_basic_article_path, method: :get, remote: true do
[20:58:01]
boytoy:
workmad3: I can try. All i have is a 2011 macbook pro with windows 7 running openbsd inside virtualbox
[20:59:17]
boytoy:
workmad3: but.. my coworker says the same as you that our app only takes a couple of minutes to precompile
[21:00:16]
sarmiena_:
boytoy: before writing a letter about something you don't know much about, probably should try locally
[21:01:08]
workmad3:
boytoy: also worth checking the terms you agreed with your ISP to see if you have any agreed upon IO performance metrics
[21:02:27]
sarmiena_:
workmad3: but to drag this on a little longer. i was here on IRC a couple of days ago asking same question. IO shouldn't me a problem when using new MBP & making sure not much else is using IO
[21:04:23]
boytoy:
just a simple su took like 1 minute, they blamed it on hardware issues and moved me to another box so
[21:04:32]
workmad3:
sarmiena_: large images could cause slowdowns, as they need loaded, hashed, etc.
[21:05:00]
sarmiena_:
yeah. still doesn't explain 600% time increase after upgrade with no asset changes
[21:05:23]
workmad3:
sarmiena_: but seems odd that moving from 3.2 to 4 caused slowdowns, as the rails 4 pipeline does a lot less work (doesn't recompile the same assets, only recompiles changed files, etc.)
[21:05:58]
workmad3:
the first one is in relation to the 3.2 pipeline always precompiling assets with and without digests
[21:07:38]
workmad3:
sarmiena_: yeah, turbo-sprockets-rails3 hasn't been ported to rails 4 because rails 4 does pretty much everything it used to do ;)
[21:09:59]
gabeodess:
Hello, I am having a strange issue with RVM where I have a gem set checked out, and when I list my gems it shows that they are all there, however, if I try to access one, say with `rails -v` it says the gem does not exist and that I need to install it. Does anyone have an idea of what I could be missing here?
[21:12:10]
honestly:
Hello rails. I'm a relative rails newbie, just hacking around on stuff, not starting from the ground up (as I maybe should, but that isn't possible right now). I'm duk3luk3 in this PR discussion: https://github.com/gitlabhq/gitlabhq/pull/5271/files I'm wondering if I'm missing something - I don't see the possible security problem I might be causing.
[21:13:05]
boytoy:
"You recently had an issue with the storage server behind my BladeVPS causing simple Unix commands to take several minutes to execute. While it appears this issue is mostly gone, there is still something odd going on."
[21:13:16]
boytoy:
"I run this simple Ruby On Rails app, and precompiling my assets (http://guides.rubyonrails.org/asset_pipeline.html) - an operation that should only take seconds to minutes - takes about 1 hour on my BladeVPS."
[21:14:07]
workmad3:
boytoy: are they likely to drop your account or cause you agro for sending the email?
[21:17:27]
boytoy:
workmad3: is this IO thing likely to impact performance once i start getting millions of visitors?
[21:17:47]
rushed:
gabeodess: it looks like that error is saying rubygems is too old (not that the rails gem is missing) you might want to find a current setup/getting started guide for your os of choice that covers getting RVM (or a similar tool) and other tools running before you get started (I believe you can substitute ruby 2.0 for 1.9 in http://ryanbigg.com/2011/06/mac-os-x-ruby-rvm-rails-and-you/ if desired)
[21:25:20]
rushed:
honestly: a non-admin submitting a form that updates the user (say one that doesn't even have an admin field) would be able to set the admin flag along with other mass-assigned fields
[21:27:04]
honestly:
(yes, it's hard to see with the discussion in between, but the formatting was already that way)
[21:28:13]
honestly:
a user should not be able to change their own projects limit or group creation privilege
[21:29:41]
honestly:
so the alternative is to file a bug and suggest that attr_accessible list is removed entirely
[21:41:53]
rhizome:
honestly: i dunno man, but admin would seem to be a special case whatever the rationale for the others.
[22:36:27]
AntelopeSalad:
does anyone know if the default disqus snippet works as is with turbolinks?
[23:05:52]
boytoy:
workmad3: is this IO thing likely to impact performance once i start getting lots of visitors?
[23:47:14]
sarmiena_:
ok so i'm working on galetahub/ckeditor to try to bring it up to date with rails 4, but running into an issue with Engine isolation
[23:47:35]
sarmiena_:
if the engine's controller inherits from ::ApplicationController, it has no access to it's own Engine helpers
[23:53:00]
sarmiena_:
so the result is, the engine's templates cannot call methods under ckeditor/app/helpers