« Back to channel list

#RubyOnRails - 08 February 2015

« Back 1 day Forward 1 day »
[00:15:18] jglover: kaymation: hey im a little confused about your implementation
[00:15:33] jglover: can you walk me through why you aren't rendering json into a template?
[01:05:03] nobitanobi: I am using the "<<" operator to add new records into a has_many through association. Since I have some uniqueness validation if I try to add a record that already exists in the has_many, I get a validation exception. How can I use "<<" but making sure that just adds records that do not exist in the assocation yet
[01:38:53] KanKava: Hi guys, what testing framework would be the best nowadays for ruby on rails develpment? and what whould be also a good e-commerce framework?
[02:04:05] Radar: KanKava: I'm a fan of RSpec+Capybara for testing, and Spree for ecommerce.
[02:25:38] arai: Anyone know of a way to pass literal javascript through coffeescript, or am I barking up the wrong tree.
[02:26:34] arai: nm, got it
[02:47:42] cleopatra: its me angain
[03:11:30] DelvarWorld: a piece of example code uses capital i Image class - but googlign for "ruby image class" doesn't return anything - is this something well known or is it specific to the library?
[03:13:06] DelvarWorld: see https://www.linkcreationstudio.com/api/libraries/ruby/ "image = Image.upload "http://url/to_your_image""
[03:17:16] cosmicfires: how can I find where the render method is defined? It's undefined in ApplicationHelper.rb
[03:34:49] ebbflowgo: i built out a concern, my understanding is lacking, I'm trying to make a extend module that can be used for multiple models calling the model via activerecord
[03:34:50] ebbflowgo: https://gist.github.com/ebbflowgo/e91a6b224eca8fbb08d1
[03:36:27] ebbflowgo: so in my Medium::Filterable::Feature.featured i would like to return Medium.all
[03:36:48] ebbflowgo: if i extended Filterable into posts then it would return Post.all
[04:49:42] tc-coug: Can anyone help me in determining why I gte a NoMethodError: undfined method ???before_action????
[04:49:54] tc-coug: trying to use Grape and Doorkeeper together
[05:20:03] spyzer: hey guys, if i have to set a globally available connection pool in rails using the connection pool gem where do I set it? in initializers ?
[05:44:16] fp-: ever since upgrading to Rails 4.2, I'm getting weird queries
[05:44:44] fp-: like I've got id columns trying to be found by strings
[05:44:54] fp-: I'm guessing this is the adequare record stuff
[05:44:57] fp-: but it's clearly buggy
[07:05:06] dmccray: hello room, having trouble getting up and running using rails 4.2 and Postgres 9.4. Trying to use the jsonb data type
[07:05:41] dmccray: can someone point me in the right direction with using form helpers with this jsonb type?
[07:16:10] FarLight: If I want to get an index of an entities children, should the route direct to a method on the parent entity, or an index method on the child entity?
[07:16:30] FarLight: entity's children*
[07:18:23] FarLight: For example, if I want to get an organization's employees, should the method be index in the employee controller, or show_employees in the organization's controller?
[07:31:28] mun: suppose a user not authenticated trying to access auth content and is redirected back to the homepage, should it be a 302?
[07:31:56] mun: or 301?
[07:32:50] FarLight: To answer my own question, the index should be in the child
[07:41:45] Technodrome: any rails 4 based cms systems?
[07:50:04] tabish: Technodrome: there are a few
[07:50:16] Technodrome: i saw refinery
[07:50:22] tabish: and locomotive
[07:50:22] Technodrome: i think that was the only one i saw that was rails 4
[07:50:32] tabish: but i think refinery is the most popular one
[07:50:47] tabish: there is radiant as well but not sure if its for 4.0
[07:51:31] tabish: i like the UI of www.caseincms.com
[07:51:52] tabish: and it supports rails 4
[07:52:26] tabish: but in terms of functionality it seems pretty low
[07:54:31] tabish: anyone here use pundit?
[07:58:38] Technodrome: tabish: its weird, radiant had the most potential but they just blew it
[07:58:58] Technodrome: they stopped developiing it , it never got to 3, they thought it was ok to just leave it on two for 7 years
[07:59:18] tabish: i think they all should come together and make one badass cms
[08:00:19] tabish: i know a few people who have worked with expressionengine (its in php) but they brag about it. Someone should start a project like that for rails
[08:00:21] Technodrome: its literally ridculous
[08:00:39] Technodrome: tabish: right now we do around 7.5M from Drupal work
[08:01:08] Technodrome: well 7.5M FTE
[08:01:32] Technodrome: yes Drupal is so popular
[08:02:15] tabish: compared to wordpress?
[08:10:00] jgt: where can I read more about logging in Rails (or in general)?
[08:10:58] jgt: I???m confused by the whole thing; should all logs just be textfiles? Should they be in some other format that???s better optimised for searching?
[08:11:16] jgt: how should I best view logs?
[08:12:08] jgt: in my day job, we run graylog, but I vaguely remember it to be a bit broken
[08:12:22] jgt: what do you people use?
[08:17:31] hd1: jgt: what aspect of logging are you talking about?
[08:18:28] hd1: http://newrelic.com/ does show you logs
[08:20:19] jgt: I mean I???m not sure on how I should approach logging
[08:21:08] Technodrome: tabish: wordpress is popular all around
[08:21:19] jgt: My intuition tells me that just reading log/production.log with less is a good strategy
[08:21:19] Technodrome: some companies use it for their blogs etc
[08:21:27] Technodrome: Drupal is popular in that enterprise
[08:21:45] jgt: s/is/isn???t/
[08:22:09] tabish: interesting. never really worked with drupal before. Did a bunch of wordpress stuff though
[08:22:57] hd1: there's also joomla, tabish
[08:23:02] sevenseacat: we picked wordpress as a cms to go with our most recent spree app. *shrugs*
[08:23:47] tabish: hd1: yea but joomla seems to be not as popular compared to the other two
[08:23:59] tabish: hey sevenseacat!
[08:24:07] sevenseacat: good afternoon tabish
[08:26:31] Technodrome: Joomla doesn???t have huge enterprise presence
[08:27:45] tabish: Technodrome: just start a new rails cms
[08:28:23] sevenseacat: sure, why not :P
[08:29:07] Technodrome: tabish: not gonna happen
[08:29:14] Technodrome: the power of Drupal is all the people
[08:29:26] tabish: c'mon you know you want too
[08:29:36] Technodrome: the powr is not Drupal
[08:29:39] Technodrome: its all the contrib modules
[08:29:48] Technodrome: Drupal without contrib modules would be no good as naything else
[08:39:29] tabish: but i don't get why people don't contribute to the rails cms. im sure drupal and wordpress started off somewhere and are where they are now because it was open source and people contributed to it
[08:39:45] tabish: sevenseacat: you have used pundit right?
[08:41:40] tabish: can you use pundit for also separating saas plans? plan 1: 5 users, plan 2: 10 users, etc ?
[08:41:48] nahtnam: In ruby, how do I remove the n'th letter in a string?
[08:42:06] sevenseacat: tabish: seems like a vague requirement
[08:43:10] tabish: i'm just trying to figure out how people do it. Where if you have a SaaS app. You have different tiers and each tier would have certain features the users can use.
[08:44:45] tabish: so the subscription plans
[08:44:46] sevenseacat: do what, exactly?
[08:45:09] tabish: actually nvm i'll come back to you with it lol
[08:45:46] jgt: nahtnam: "some string".split("").delete_at(n)
[08:46:14] jgt: nahtnam: and then join
[08:46:59] jgt: actually
[08:47:10] jgt: that doesn???t work
[08:48:05] jgt: nahtnam: I can make it work by not chaining them
[08:48:27] nahtnam: jgt: Well its just a string of 5 random numbers/letters
[08:49:03] nahtnam: If that helps
[08:51:38] jgt: shouldn???t make a difference what the string looks like
[08:52:02] nahtnam: jgt: Oh ok.
[08:52:17] jgt: I???m sure there???s some sugary way to do it in stdlib, but until I discovered it, I???d defined a method for it
[08:53:02] jgt: and at a high level, the method would split the string into an array, delete an array element at a given index, and return the joined array
[08:53:32] sevenseacat: i dont think theres anything in stdlib to do it directly
[08:54:33] jgt: sevenseacat: I still think of Rubby as magical Mary Poppins, who has every conceivable method in her bottomless stdlib handbag
[08:55:02] sevenseacat: if it was even a relatively common idea, it probably would be
[08:55:39] jgt: recipe for sad programmers: ???<x> language is shit! It doesn???t even do <y>!???
[10:07:37] Technodrome: tabish: its very weird isn???t it?
[10:07:51] Technodrome: yes the rails cms???s , hardly no one contribs, just the 1-3 people who start it
[10:08:12] Technodrome: refinery tried to make it a bit like Drupal, but in the end, realized that it was just them 4 working on it
[10:08:51] Technodrome: and if all you had with Drupal was drupal and its core modules, it would be fairly feature compatible to say refinery, but its the community which changes all that
[10:24:00] jammanbo: I'm going to be asking this periodically all day: Does anyone have an example of using [shallow] nested Rails resources with Ember? I don't want to do the embedding/side loading thing. I want to get Ember talking to the nested Rails API resources directly, and with as little hackage as possible ...
[10:43:06] matDobek: hey, Ive just read about NullObject pattern, and have one q: Is it cool, when using ActiveRecord to use User.new( first_name: '', last_name: '' ), instead of creating NilUser class?
[10:47:38] naftilos76: Hi i want to make a scaffolding for model User and give the attributes of the db like username, password, address etc. However i know the basics as far as types of attributes are concerned i.e: username:string counter:integer ... What about passwords or country select combo boxes? Can anybody point me with a link?
[10:49:28] sevenseacat: well passwords are strings
[10:50:21] sevenseacat: depending on how youre storing country data, it might be a string, or it might be an integer for a foreign key reference to a countries table
[10:52:17] naftilos76: well, yes i know that. I was wondering if there was something that could instruct scaffolding to use a password_field rather than a normal text_field as well as instruct scaffolding to use a select_date (or whatever is meant for datetime or country select)
[10:52:48] naftilos76: instead of ordinary text fields
[10:53:50] naftilos76: I guess defining username:string etc primarilly targets the db formation and not the scaffolding process
[10:56:11] sevenseacat: scaffolding isnt meant to be the be-all and end-all of your app - its a starting point
[10:56:20] sevenseacat: if you use it at all, which i dont recommend
[10:58:08] naftilos76: i know that sevenseacat, i am at a starting point!
[10:58:24] sevenseacat: okay, so you generate your scaffold, and then you change things as necessary
[10:58:35] naftilos76: yep, exactly
[10:58:36] sevenseacat: if you want a password field, you change the views to make it a password field
[11:03:52] naftilos76: What do you recommend as far as passwords are concerned? Use js to produce a SHA string or do it with ruby in the model before passing in the controller? I will of course check if the string is encrypted , on the server side, and will encrypt it there if i need to. I will always be on SSL.
[11:04:38] sevenseacat: personally, i'd just use devise, which bcrypts passwords before saving them to the db.
[11:05:41] naftilos76: I mentioned SHA as it is a common way of doing things but other ways are definitely accepted as long as they add extra security! Thanks.
[11:06:05] sevenseacat: sha is not common in ruby.
[11:06:48] sevenseacat: helpful people are assumed to be men?
[11:07:48] naftilos76: my apologies
[11:08:44] naftilos76: in fact i think women are better in supporting others!
[11:10:14] rushed: naftilos76: if you're trying to improve the situation probably want to just stop with the generalizations :)
[11:13:20] naftilos76: You don't mean to be aggresive, are you? I am not trying to improve anything...
[11:15:05] rushed: naftilos76: nope, honestly trying to help future-you by pointing out that anytime you decide to start with "I think x are..." where x is a large group of people you're probably making an ass of yourself :)
[11:15:29] rushed: naftilos76: unless x is Windows users and you're here... in which case echo chamber on my friend~
[11:16:56] naftilos76: rushed: I get your point. I am sorry if i offended anyone.
[11:40:25] geo31: How can I analyze the server load right when a particular function in my rails app runs?
[11:43:53] tabish: Technodrome: i guess its because people already know there are already a few cms out then they don't bother with making them or putting too much time/effort into it
[12:38:51] lxsameer: hey guys, does log4r supports log rotation ?
[13:22:52] mostlybadfly: tabish: hey good morning, did you ever get a chance to look at that?
[13:23:09] mostlybadfly: still weird, can't seem to find the issue
[13:24:37] tabish: hey mostlybadfly: sorry I did clone your repo and started to look at it but had to step out and haven't had a chance to as of yet. I'm getting out of the office in about an hour or so and will take a look at it then
[13:25:10] tabish: if you have twitter add me tabishiqbal_ i'll give you a msg if it is working
[13:25:56] tabish: or if you see me in a few hours then msg me on here
[13:26:21] mostlybadfly: cool thanks, tabish . I really appreciate it!
[13:32:19] tsujp: Can anyone explain to my why I have to use self.matches? on a routes.rb constraint
[13:32:30] tsujp: I can't find any documentation on the `matches` method
[13:32:54] tsujp: Why can't I create a class with multiple methods accepting a request for some subdomain rouiting
[13:33:00] tsujp: Class Subdomain
[13:33:05] tsujp: def self.matches?
[13:33:25] tsujp: Why can't I have methods inside of those instead
[13:33:31] tsujp: Why must it be in self.matches?
[13:37:55] tsujp: Anyone here?
[13:53:08] tabish: tsujp: self.method_name defines a class method
[13:53:24] tsujp: I know that but what's so special about matches
[13:53:30] tsujp: Why can't I use any other name other than matches
[13:53:52] tsujp: So that I could have 5 constraints under the Subdomain class and call them as follows: :constraints => Subdomain.something
[13:54:00] tsujp: :constraints => Subdomain.something2
[13:54:07] tsujp: Why must it be self.matches?
[13:54:12] tsujp: self.something?
[13:54:24] tsujp: What is "matches?"
[13:54:35] tsujp: tabish: check above~
[13:58:41] tabish: tsujp: https://gist.github.com/tabishiqbal/a49a7c66054751ae026c sorry the indent. is off
[14:00:10] tabish: .matches checks the request coming in and based on that uses the constraints in the routes
[14:13:40] tsujp: tabish: cheers for that but I'm trying to match static domains to some specific actions
[14:14:16] tsujp: tabish: for instance admin and api, and I don't want to have to write two classes just to accomplish this
[14:14:28] tsujp: tabish: admin.domain.com api.domain.com
[14:20:11] tsujp: tabish: check this gist: https://gist.github.com/tsujp/33a291516f9e816ab846
[14:21:08] tabish: ohk. give me a few mins to look at it
[14:21:10] rushed: tabish: http://guides.rubyonrails.org/routing.html#request-based-constraints
[14:21:30] lesnik_: I have a Notification model. Each notification has a read attribute, which says was this notifaction was read or not. In the index action I'm doing @notifications = Notification.where(...). Now in the view I want to mark all unread notification by a special color, and I know how to do it. The problem is that after getting this notifications in controller, I have to change their read attribute to true in the database. So I'm doing Notification.where
[14:25:45] rushed: lesnik_: did you mean to leave that question truncated?
[14:31:12] lesnik_: rushed: you mean the where(...) part?
[14:31:33] rushed: lesnik_: "So I'm doing Notification.where" <= that's the end of your question?
[14:31:58] lesnik_: rushed: nope, that's all what you see?
[14:32:17] rushed: lesnik_: ya you can only paste so much on one line :)
[14:32:41] lesnik_: didn't know
[14:34:06] lesnik_: I have a Notification model. Each notification has a read attribute, which says was this notifaction was read or not.
[14:34:11] lesnik_: In the index action I'm doing @notifications = Notification.where(...).
[14:34:16] lesnik_: Now in the view I want to mark all unread notification by a special color, and I know how to do it.
[14:34:24] maodun: I have a url structure like /cities/mycity/foo/bar/baz?various-params-here, I want to be able to handle urls where mycity is "current" and redirect the browser to the correct geolocated city. But I want to leave the rest of the url structure intact. How can I do a redirect while just changing the mycity part?
[14:34:27] lesnik_: The problem is that after getting this notifications in controller, I have to change their read attribute to true in the database. So I'm doing Notification.where(id: @notifications.ids).update_all(read: true).
[14:34:34] lesnik_: But this line changes also @notifacions, so in the view looks that all notification are already read. How to fetch notifications, pass them to the view as not read, but change their read attribute in the database at the same time? :)
[14:36:40] rushed: lesnik_: I thought update_columns went straight to the db, you sure it updates @notifications?
[14:38:56] rushed: lesnik_: also, if you're always going to mark them as read, you might consider telling the view everything is read, ie @everything_is_already_read = true and then add a short circut to the conditional for your css class logic (or whatever) in the view
[14:40:14] rushed: lesnik_: nix that second part, opposite of what you're trying to do :P
[14:41:33] tsujp: tabish: posted a stack question here: http://stackoverflow.com/questions/28395181/rails-routing-more-complex-constraints
[14:44:11] rushed: tsujp: what are you trying to do?
[14:50:29] tsujp: rushed: Im trying to create routes for admin, api, and a few other static subdomains with their resources attached
[14:51:09] tsujp: rushed: currently this solution get "/" => "admin#index", :constraints => { :subdomain => /(www.)?admin/ } does not allow me to assign resources to a specific subdomain, e.g. resources :admin
[14:51:21] tabish: tsujp: but you don't want to do the self.matches? to see if the subdomain is present or not and that the subdomain is not 'www' ?
[14:51:37] tabish: are you using apartment gem? or anything else or rolling your own
[14:51:49] tsujp: tabish: Well I only want to do that because I can't get resources on the `get`
[14:51:52] tsujp: tabish: no gem
[14:52:16] rushed: tsujp: why do you need the class, what can't you do with just constraints: { subdomain: /regex/
[14:52:31] tsujp: rushed: because I can't get resources that way
[14:52:46] tsujp: rushed: unless you can show me how to get resources using this get "/" => "admin#index", :constraints => { :subdomain => /(www.)?admin/ }
[14:52:59] lesnik_: rushed: the problem is that rails tries to be smart, and first do the update then load notifications....
[14:52:59] tsujp: rushed: adding resources :admin breaks it completely
[14:53:07] lesnik_: @notifications = Notification.where(target_user: current_user.id).page(params[:page]).order(:created_at)
[14:53:10] lesnik_: Notification.where(id: @notifications.ids).update_all(read: true)
[14:53:13] lesnik_: render layout: false
[14:55:48] tsujp: rushed: know any way rushed?
[14:57:22] rushed: lesnik_: ah, got it, maybe throw in a @notifications = @notifications.to_a before the update_all to make sure you have your copy out of the db beforehand :)
[15:01:29] rushed: tsujp: not sure I follow, breaks what? are you saying you're not able to put "resources :admin" inside a "constraints subdomain: /(www.)?admin/ do" block?
[15:02:14] rushed: tsujp: side note www.admin.foo.com seems like a weird thing to have floating around to begin with :P
[15:03:56] lesnik_: rushed: worked the way you wrote
[15:04:19] lesnik_: thanks, but can you explain me why rails do it this way?
[15:06:13] rushed: lesnik_: before you iterate on it it's an active relation, so you can continue chaining where clauses or whatever on it, it's not materialized into a query that gets run until you actually touch it
[15:06:39] naftilos76: Hi, is validates_confirmation_of broken in rails 4.2 ?
[15:07:16] lesnik_: rushed: thanks for the explanation
[15:12:00] naftilos76: User model: http://pastebin.com/WpMimJse , View (part of): http://pastebin.com/LF5VqMbe
[15:13:41] naftilos76: Can anyone confirm why validates_confirmation_of doesn't work?
[15:13:50] naftilos76: in rails 4.2 ?
[15:14:31] rushed: naftilos76: why do you think it doesn't work?
[15:16:15] naftilos76: I am using the code given above to get basic functionality of creating a user but when i leave the pwd confirmation empty or enter any string i do not get any warning messages.
[15:18:19] naftilos76: The database attribute is password not password_digest as bcrypt requires
[15:19:57] mib_mib: hi all - i'm trying to use paranoid gem that soft deletes a model - and cancan's load_and_authorize_resource doesnt find the record so it errors - how can i allow load_and_authorize_resource to search for MyModel.with_deleted scope (but not set this as default scope on the model)
[15:20:27] rushed: naftilos76: for the empty case you should probably have something like... validates_presence_of :password_confirmation, if: :password_changed?
[15:21:42] naftilos76: rushed: what about the confirmation? Shouldn't i get a warning that the two passwords do not match when i enter different strings?
[15:22:24] naftilos76: It looks straightforward but i have been struggling for a few hours...
[15:22:41] rushed: naftilos76: are you sure you're not? does the model save?
[15:23:18] naftilos76: rushed: yes of course it saves
[15:23:33] naftilos76: i can see the saved row
[15:23:45] naftilos76: i can edit it and delete it
[15:24:48] rushed: naftilos76: have you added the validates_presence_of and does the blank case work?
[15:25:05] rushed: naftilos76: if so, gist the params for a request that saves a user w/out error and the controller code
[15:25:21] naftilos76: ok give me a moment
[15:32:02] naftilos76: rushed: i added => validates :password_confirmation, presence: true, length: { minimum: 4 } and i get warnings related only to presence but also the confirmation is empty after i submit the form and therefore the warnings are justified. Somehow the password_field is empty after the submission while the password field (not confirmation) value is present (dots only).
[15:33:45] rushed: naftilos76: are you allowing :password_confirmation in your strong params? should be a log warning if it's pitching stuff, but double check that the params bits in the log on the way in are as expected
[16:26:16] JyZyXEL: if i have before :each do FactoryGirl.create :user end
[16:26:28] JyZyXEL: how do i make the 'user' show up in describes
[16:26:46] JyZyXEL: i tried: let!(:user) { FactoryGirl.create :user }
[16:26:50] JyZyXEL: but it doesnt allow that
[16:32:58] roamingdog: JyZyXEL: what error?
[16:33:22] JyZyXEL: i just deleted the whole before block
[16:33:27] roamingdog: JyZyXEL: i think let! gives you an instance var no?
[16:33:43] JyZyXEL: you cannot use let! inside a before block
[16:34:00] roamingdog: JyZyXEL: no, use it above the before block, if you need a before block
[16:34:47] JyZyXEL: yeah thats the correct solution
[16:52:44] bronson: Just published a gem, hoping for suggestions / first impressions? https://github.com/bronson/geolocal
[16:52:51] bronson: Especially anything that I might have left confusing
[16:57:36] roamingdog: bronson: looks interesting, little typo in readme: "Allows IP addresses to geocoded with a single Ruby if statement." perhaps "to be geocoded"?
[17:01:46] bronson: roamingdog: yes, thanks!
[17:04:15] bronson: fix: Geocode IP addresses with a single Ruby if statement.
[17:37:16] teufelChiCoder: i got pow installed, but when i try to access a localhost IP address, i get a screen that says "POW is installed", how do i bypass it?
[17:39:57] platzhirsch: AR, on a relation, can I limit and order the results? Like user.blocked_users <- want to limit and order that one, do I have to do BlockedUsers.all(:user_id => user.id ... first?
[17:40:11] platzhirsch: or is there something similar to user.blocked_users.limit(100).order...
[17:40:33] JDeen: I am trying to create a plugin in Rails (4.2) that has some javascripts. I did a `rails plugin new pulgin_name`. Added the js to `vendor/assets/javascripts/plugin_name/jqury.plugin.js`. When I added the gem to a test app, run bundle install, and require the plugin, I get the error that the file can't be found. Do I need to do some thing else?
[17:42:05] Denarii: platzhirsch: user.blocked_users.limit(100).order(...) should work
[17:42:19] platzhirsch: Denarii: doesn't though.. Rails 2.3 here,, maybe that's why?
[17:42:40] Denarii: ah, I dunno, never used Rails older than 3
[17:43:22] ylecuyer: Who can explain me where I should put page specific javascript in rails 4?
[17:46:33] JDeen: ylecuyer: I am Sinatra guy playing with Rails, but as I understand there is nothing 'page specific'. I normally write coffeescript classes and use requirjs in Sinatra. In rails what I did was in the `constructor` method I check if a certain data attribute `data-page='contact'` exists and if so to continue the rest of the class.
[17:48:00] teufelChiCoder: i got pow installed, but when i try to access a localhost IP address, i get a screen that says "POW is installed", how do i bypass it?
[17:48:54] JDeen: ylecuyer: How ever I would like to know if there is a way, nothing that I have come across.
[17:50:14] ylecuyer: jdeen: I have already read some similar answers on the web but I wonder if there is a better solution than this
[17:50:59] ylecuyer: It's strange that this problem hasn't already been pointed out and fixed
[17:56:32] JDeen: ylecuyer: Every thing gets compiled to one file, thats the problem I think. And adding a simple condition can avoid the need for a new machanism. In one of our projects we used a custom 'router' CoffeeScript class to dynamically load required assets for a page. It wouldn't be elegant but will be possible with rails. So you add a script tag for the layout which requires the router. The router decides based on the route / config to load the necessary files
[17:58:13] JDeen: If you don't do it like that, as I am aware, you will have issues when using things like PJAX and TurboLinks (Pjax, thats why we had to use a custom router class)
[18:01:06] JDeen: I am trying to create a plugin in Rails (4.2) that has some javascripts. I did a `rails plugin new pulgin_name`. Added the js to `vendor/assets/javascripts/plugin_name/jqury.plugin.js`. When I added the gem to a test app, run bundle install, and require the plugin, I get the error that the file can't be found. Do I need to do some thing else?
[18:29:41] rails_noob: hey there guys, I am trying to find the best way to itterate through a form while seperating the questions, hopefully either 5 at a time, or according to their subject_id. I would like to do it this way as the form is very long, I would like to not have to hardcode the breaks as I need the form to be dynamic, and I don???t want to use javascript if it isn???t going to send the information until all the data is filled in,
[18:29:42] rails_noob: incase a user decideds to stop half way. Any adivce?
[18:30:34] mnms_: eager_load = true loads most of Rails app in memory. What does it mean most
[18:30:59] mnms_: as far as I see views are not cached
[18:37:54] amrtnz: hi, can somebody help me with deploying a rails app?
[18:38:30] amrtnz: Everything is going great using digitalocean's rails + nginx image, but whenever I try to send mail it never gets received
[18:42:12] mnms_: amrtnz: in rails logs you have line about sending email ?
[18:44:47] amrtnz: mnms_: what's the best way to provide the logs for you to see? I'm not sure which log will be most useful
[18:45:19] amrtnz: now i'm getting a new error: Net::OpenTimeout in Devise::RegistrationsController#create
[18:46:11] mnms_: amrtnz: so you cannot connect to your smtp server
[18:46:30] amrtnz: I'm using smtp.gmail.com
[18:47:43] mnms_: Try to login to your gmail account, maybe they blocked temporary sending emails and you need to prove you are not robot
[18:48:55] amrtnz: ok so I logged in but under sent mail there is nothing
[18:51:25] mnms_: can you connect from DO to smtp.gmail.com or server address which you have defined in environment.rb file
[18:51:31] mnms_: from console
[18:51:37] mnms_: using telnet
[18:55:47] JyZyXEL: is it possible to make a query to a database and ask for what is the 'category' with best average 'vote'
[18:58:57] JyZyXEL: how do i even go about creating something like that?
[18:59:42] beauby: JyZyXEL: look at JOIN and MAX
[19:00:37] JyZyXEL: i probably need to calculate averages for every category and then take the highest one
[19:03:15] JyZyXEL: beauby: there is no multiple tables
[19:03:29] tc-coug: anyone worked with Grape and Doorkeeper before?
[19:04:47] rails_noob: hey there guys, I am trying to find the best way to itterate through a form while seperating the questions, hopefully either 5 at a time, or according to their subject_id. I would like to do it this way as the form is very long, I would like to not have to hardcode the breaks as I need the form to be dynamic, and I don???t want to use javascript if it isn???t going to send the information until all the data is filled in,
[19:04:47] rails_noob: incase a user decideds to stop half way. Any adivce?
[19:05:31] tc-coug: I???m trying to get the current_resource_owner from a Grape API
[19:05:36] tc-coug: but have been unsuccessful
[19:09:01] cmeks: is it possible to call another controller method within the same controller like this.. another_method(object)
[19:09:12] cmeks: basically i have this
[19:09:40] cmeks: render 'edit'
[19:09:49] cmeks: but i want to try to call the edit method
[19:10:00] cmeks: and pass in the id of the thing
[19:10:02] cmeks: i want to edit
[19:10:15] cmeks: as soon as the create method finishes
[19:11:56] tc-coug: if object.save
[19:12:20] tc-coug: redirect_to edit_object_path(object)
[19:13:33] _mynameis: cmeks, not sure if relevant, but have you tried to move the method code into the helper and accessing it from the controllers?
[19:14:03] cmeks: thanks coug
[19:15:13] maze24: Hello, Can somebody help me with this please? I am trying to create a reservation system. I have setup a controller to create a reservation, which itself loads other models, such a group (what the client has to chose). How do I allow a client to select a group and save its id in the reservations table?
[19:15:56] glcheetham: maze24: do you have a model for the reservation?
[19:17:03] glcheetham: maze24: Then you should generate a form for the model in a view (http://guides.rubyonrails.org/form_helpers.html) and then call reservation.new in the create action in the controller
[19:17:04] hypnosb: I want models Rainfall and Location and relate these through a single Projection, a single projection could have many Rainfalls and Locations Projection (id:1, Rainfall[1,2],Location[1,2]) ... I'm not really sure how to do this as the ERD I come up with can only map a single projection to a single rainfall and location? http://dpaste.com/2HMH9G1
[19:17:07] noober3: you create a form
[19:17:24] hypnosb: I saw there is an array column type in postgres?
[19:17:30] maze24: glcheetham: I've done that, everything works perfectly
[19:17:39] hypnosb: what is the 'normal' way to look at this?
[19:17:40] glcheetham: maze24: if you made the model and controllers with rails g scaffold or rails g controller you should already have most of the stuff there
[19:18:03] maze24: glcheetham: What i want to do is display groups of items a user can reserve
[19:18:20] maze24: glcheetham: and allow the user to select 1 group when creating a reservation
[19:18:24] glcheetham: hypnosb: Yes, there is, check the postgres wiki. Also, you can call :serialize in your models to store json-arrays in other databases
[19:18:28] tc-coug: anyone use Grape and doorkeeper before, I???ve got an API that inherits from Grape::API
[19:18:29] tc-coug: how do I access the doorkeeper_token?
[19:18:36] glcheetham: hypnosb: (as strings)
[19:18:38] maze24: glcheetham: So its a form in a form i guess
[19:19:19] hypnosb: glcheetham, is that the 'way to do it?' or is it possible to do this all in table relations? Are there ORM gotchas for storing keys in an array?
[19:19:25] glcheetham: maze24: I would acheive that kind of thing with a dropdown (select tag) which links up to a model. CHeck out the API reference for select_tag
[19:20:14] glcheetham: hypnosb: It depends on what sort of data you decide to store. Some data, for instance, might deserve a table of it's own
[19:20:50] hypnosb: glcheetham, I'd imagine I would have a separate Projection_data table ...
[19:21:07] hypnosb: biggest hurdle right now is aggregating multiple Locations and Rainfalls to a single Projection
[19:22:15] glcheetham: hypnosb: If you're storing something like metadata in the column or you know that the keys will always be the same then I guess array/serialize is that way to go. Otherwise, creating a new table will save you alot of headache
[19:22:41] glcheetham: hypnosb: You could also check out the NoSQL/Document store route with MongoDB/etc
[19:24:11] maze24: glcheetham: I've thought of using a select tag, but i would live to display an image and some other things for each group
[19:24:34] maze24: glcheetham: i don't think that can be done with a select_tag
[19:25:23] hypnosb: What is the new table? I cant see how this could work in a full relational db.. but I am newb so :D
[19:25:33] glcheetham: maze24: You could look at using some javascript to show/hide content in relation to the select tag?
[19:25:41] _mynameis: Guys, is it possible to create such an input field in Rails that would store all the ids of the objects related to a "parent" in the has_many :through relationship? And create new relationships if more ids were added?
[19:26:12] _mynameis: Those ids would be separated by commas.
[19:27:07] glcheetham: mynameis: You may want to look at a form builder gem (https://www.ruby-toolbox.com/categories/rails_form_builders)
[19:27:13] maze24: glcheetham: is it possible displaying the data inf a form like: <% @groups.each do |group| %> then be able to select on of them using a radio button and assign it to group_id in the reservations table?
[19:27:24] glcheetham: mynameis: Also, remember that you can pass blocks to the form helpers
[19:27:51] _mynameis: Alright, thanks a lot. I'm trying to implement jquery-tokeninput in Rails 4 but have been failing so far
[19:28:49] glcheetham: maze24: Unfortunately there is only so much help I can give you with the architecture of your application over an IRC channel. I find that I have eureka moments by taking a ten-minute break from the code and getting a coffee :-)
[19:29:42] maze24: glcheetham: True, I guess i need a break! Thanks
[19:30:26] glcheetham: maze24: Haha, lots of problems can often be solved by structuring the same data in a different way. Good luck :-)
[19:30:53] hypnosb: glcheetham, yeah i realize that... thats why im smashign my head against this
[19:32:25] glcheetham: hypnosb: You'll find that rails will do alot of the work for you if you start doing things "The Rails Way". It feels strange for a programmer to conform in such a way, however, simple things like using resourceful routing and using the scaffold generators can be the difference between spaghetti and zen code sometimes.
[19:32:35] JyZyXEL: how do i join my user.ratings table with the 'item' table?
[19:33:12] JyZyXEL: the user.ratings has user_id, item_id, score and items table has item_id and category
[19:33:19] glcheetham: JyZyXEL: If you're not using associations yet, http://guides.rubyonrails.org/association_basics.html, read the articale and start doing so
[19:33:39] JyZyXEL: i am using those
[19:33:53] JyZyXEL: the structure is set up using associations
[19:34:35] glcheetham: JyZyXEL: Lots of things fall into place by using associations. But in your case, try here http://guides.rubyonrails.org/active_record_querying.html#joining-tables
[19:35:57] JyZyXEL: ah, user.ratings.joins(:item)
[19:37:37] JyZyXEL: well it didn't add any new information
[19:37:57] JyZyXEL: i was hoping to get the item details joined with the ratings but that didn't happen
[19:38:44] glcheetham: JyZyXEL: Perhaps pastebinning some code would help me help you.
[19:40:50] noober3: i have a discounts table with colums such as Tenant, Car Rental that holds decimal values. The table also has a column called dollars_or_percentage that holds a string that stores whether the discount should be a dollar amount or percentage amount. Is there an easy active record query to find the max dollar discount for each column that I have, looking through multiple table records?
[19:41:29] hypnosb: glcheetham, so im assuming the keys wont change much per projection, they are just IDs.. if anything a new projection can use an existing Rainfall id... I'm just so torn between the whole Relationship model... took a db class and they beat me with normalization
[19:41:57] hypnosb: vs serializing the ids
[19:58:18] mkc: hey, i once found a gem that helps with working with timedate, when working on building a reminder service. Can anyone name any gems that you know of that would handle that problem
[20:00:56] alecs: mkc: try http://ruby-toolbox.com
[20:05:38] neruda: hi, do i have to "build" a corresponding object for each section of a complex nested form, or does nested attributes in the model make that unnecessary
[20:11:49] Houli: having some difficulty with controller tests and has_and_belongs_to_many associations
[20:12:47] Houli: my model validates the presence of category ids for posts
[20:14:45] Houli: not sure how to modify my tests to provide these ids using fixtures
[20:17:21] Houli: i'm assuming that some kind of reference to categories must go in the line "post :create, post: { description: @post.description, title: @post.title }"
[20:19:09] Houli: this is in the scaffolded "should create post" test just for reference
[20:28:05] Houli: i can try dummy values for the category ids but this fails as those categories don't exist
[20:41:13] symbole: How does the sytnax look for an includes when I have two assocations? The rails guide has `Article.includes(comments: :guest)` but what if I also wanted to join comments on something like users?
[20:42:03] symbole: Would it be Article.includes(comments: [:guest, :user])?
[20:51:09] JyZyXEL: if i define a method in model, how do i show the output of the method in view?
[20:51:52] JyZyXEL: ah, works straight
[20:53:18] Technodrome: it annoys me so much there is not a good CMS for rails, omg it does
[20:56:48] cmeks: Does anyone have a link to a good guide for editing popup windows
[20:57:31] cmeks: all the ones i'm finding off of google either don't make sense or aren't telling me what i want
[21:06:40] JyZyXEL: code_climate:
[21:06:42] JyZyXEL: repo_token: adf08323...
[21:06:43] JyZyXEL: what the heck is a repo_token?
[21:12:08] Radar: Good morning
[21:12:15] Radar: JyZyXEL: It's probably a token for a repo.
[21:12:25] Radar: Just guessing.
[21:12:29] JyZyXEL: yeah i think its the token that Code Climate gives me
[21:15:31] naftilos76: Hi everyone, i want to update the attribute 'updated_at' of sessions table. I used to do it in rails 2.1 with session.model.update_attribute() . Does anybody know how it can be done in rails 4.2 ?
[21:25:44] JyZyXEL: remote: No Procfile detected, using the default web server (webrick)
[21:25:50] JyZyXEL: how can i get rid of that warning?
[21:28:04] Houli: JyZyXEL: that means you haven't created a heroku procfile
[21:28:08] kara_sweets: hey guys i have a partial that I reload using javascript every 5 seconds (polling with js.erb)
[21:28:26] Houli: they have a detailed guide here about setting up rails on heroku https://devcenter.heroku.com/articles/getting-started-with-rails4
[21:29:06] kara_sweets: i have 2 calls that involve the db in the partial, i.e. current_user.conversations however even though the partial is getting called and loaded, theres no query being made
[21:33:27] kara_sweets: https://gist.github.com/anonymous/1359f880907ecbbb26f6
[21:33:53] kara_sweets: lines 6 and 7 are not reflecting the up to date info
[21:38:51] johntrails: does anyone know where i can find some tutorials. I am looking for to learn some specific things. I want to be able to incorporate calendars in my app to perform range selections. I want to pull data from my models from within a specific range of dates. ideally i would have 2 calendars to select begining and end date
[21:40:48] Sawbones: SHould my models files be capitalized singlular?
[21:40:52] Sawbones: or lowercase?
[21:43:51] Radar: Sawbones: Where?
[21:44:04] Radar: johntrails: Have you gone through Rails 4 in Action yet?
[21:45:10] johntrails: Radar, no, is this a book?
[21:45:16] Radar: johntrails: !r4ia
[21:45:16] helpa: johntrails: Rails 4 in Action - http://manning.com/bigg2 - An excellent book combining Rails and TDD/BDD development. Written by Steve Klabnik, Ryan Bigg, Yehuda Katz
[21:45:22] Sawbones: Radar: Rails models
[21:45:23] Radar: johntrails: use code cftwbiggs2 to get 44% off
[21:45:30] Radar: Sawbones: !explain
[21:45:30] helpa: Sawbones: Please explain your problem better as we are having trouble understanding what you mean. A Gist (http://gist.github.com) is always helpful!
[21:45:35] Radar: Sawbones: Show us an example of what you mean.
[21:45:42] johntrails: Radar, thanks.
[21:46:23] Sawbones: I'm asking if the filenames of my rails models should be capitalized, should it be User.rb or user.rb
[21:47:14] Radar: Sawbones: See above link, and also...
[21:47:16] Radar: Sawbones: !gettingstarted
[21:47:16] helpa: Sawbones: http://guides.rubyonrails.org/getting_started.html - Getting started with Ruby on Rails guide written by Mike Gunderloy
[21:50:50] Moeh: What is the recommended setup if I have to dynamically create and remove background jobs while the rails app is running?
[21:51:53] voker57: use something like sidekiq
[21:52:00] Sawbones: ctrl + f 'uppercase'
[21:53:04] Radar: Sawbones: ffs dude
[21:53:08] Enkele: I need to put login form in the bootstrap modal. Anybody tried that?
[21:53:29] Radar: Sawbones: Read the damn guide. I am not going to give you your answers especially when it's already in the guide.
[21:53:40] Enkele: devise login
[21:53:44] Radar: Sawbones: Sections 5.4 and Section 6.1
[21:53:53] Moeh: Voker57: Yes, however it does not seems optimised for the use case of creating new jobs programmatically but rather for defining methods that will run in the background beforehand.
[21:53:58] Radar: Sawbones: And why aren't you using the model generator anyway?
[21:54:18] Sawbones: the model generator takes into account if you capitalize it or not
[21:55:06] Radar: ... and what file does it produce?
[22:37:33] fabionl: how can I prevent rails from sending session cookies ? (essentially remove Set-Cookie header from response) I have that but it's not working: http://pastie.org/9910402
[22:38:47] fabionl: I need it for an API that I am building..
[22:48:20] Radar: F__i__L: Why do you need it?
[22:48:27] Radar: F__i__L: What is wrong with having that header?
[22:48:49] fabionl: Actually I don't any problem with the header as long as it's empty
[22:50:09] ap4y: F__i__L: try Rails.application.config.session_store :disabled in config/initializer/session_store.rb
[22:51:06] fabionl: ok good idea ap4y but the thing is that I want to disable the session store only for my API endpoints, not for the whole app
[22:51:43] Radar: F__i__L: Why does it matter if the header is set?
[22:52:05] Radar: F__i__L: !g remove set-cookie rails
[22:52:08] helpa: Do your research before hand. Your question may be answerable with a quick Google search or by simply experimenting. If you're using a method in Rails, look it up in the API Docs or in the Official Guides.
[23:03:07] capin: afternoon
[23:15:13] renegadeandy: Hi. I have added a new method to my event model, but when i try to call it from my controller, it shows an error saying undefined method calculateSavingPerTerm : https://gist.github.com/anonymous/93e9a78dea206c13008c
[23:18:01] koriner: renegadeandy: you've declared it as a static method (using self)
[23:19:14] renegadeandy: koriner: aha, so remove self and it should work?
[23:19:45] koriner: I'm assuming you're setting the @event variable somewhere in your controller to?
[23:19:53] renegadeandy: koriner: that did - nice. How within that model method, can i access the current requests event object?
[23:20:16] renegadeandy: so instead of doing return 10.99 i could do return event.price * 2
[23:20:47] koriner: just do "return price * 2"
[23:21:06] koriner: that will use the instance's price
[23:24:08] renegadeandy: terrific thank you koriner
[23:24:24] koriner: renegadeandy: no worries
[23:24:54] koriner: you can also use "self.price" inside an instance method, which points to the current instance
[23:25:02] koriner: but it's not necessary
[23:25:52] koriner: but if you declare a method with "def self.method", that makes it a class/static method
[23:27:31] renegadeandy: koriner: sure
[23:27:53] fp-: my app relies heavily on 2 API services and my lib directory has gotten pretty darn big... is there a better folder naming idea for these api clients?
[23:31:00] Radar: fp-: app/clients?
[23:31:11] Radar: fp-: protip: you can create more directories under lib
[23:33:06] fp-: yeah i've got the 2 of them organized into subfolders with lib
[23:33:13] fp-: they are nearly gemmable
[23:33:27] fp-: this is for proprietary stuff though, so no sense in making it a gem to release
[23:34:42] alecs: fp-: you can make them gems and use it from your private git
[23:58:55] fp-: i spent the better part of yesterday trying to figure out how to make them gems while developing in rails
[23:59:04] fp-: had nothing but trouble with autoloading issues
[23:59:11] fp-: ended up moving them back to lib/
[23:59:37] Radar: fp-: Moving them to gems is a good idea just because you can isolate them completely from your app's code.
[23:59:43] Radar: Then you can test them in that isolation.
[23:59:52] Radar: Unless those clients *need* to reference models/whatever