#RubyOnRails - 04 August 2017
« Back 1 day Forward 1 day »
[00:05:01] DenSchub: hey - developing a rails5 application with an api, wondering about api versioning. what's the best way to establish some kind of versioning?
[00:21:31] fugee: jquery datetimepicker pops up when i click in the field but after it closes on a selection the fields still unpopulated (blank)
[01:44:11] havenwood: DenSchub: here's some discussion along those lines that might be interesting if you haven't read it yet: https://github.com/json-api/json-api/issues/406
[01:46:13] DenSchub: namespaces seems hacky because of issues with sharing classes between versions, and there does not seem to be a clear "best practise" on the rails side of things
[01:50:06] havenwood: DenSchub: here's an interesting take on it combining vnd accept header and scope namespace: https://scotch.io/tutorials/build-a-restful-json-api-with-rails-5-part-three
[01:52:21] DenSchub: yeah, and if we go down the chain we quickly get to a point where we want to version the serializers as well, because that makes sense, and you run into issues like https://github.com/rails-api/active_model_serializers/issues/1442
[02:50:00] fugee: i'm having a problem with jquery datetimepicker and i saw a post recommending to require jquery-ui instead of jquery2 if i'm gonna use jquery datetimepicker and to also put the gem in my Gemfile I'm presently using jquery datetimepicker without the gem in my Gemfile just with require jquery2 makes it available
[02:51:52] mices: my problem is it doesn't populate the field it leaves it blank, if it launched datetimepicker when i clicked in the field i take that to mean there's no error in my code
[05:10:45] ImmoveableOne: Hello, I have a bit of a unique problem. I want to process and save(to a file) the parameters to every method call I make in rails, be it in a library, helper controller or model. Is there a universal method filter or some such I can use?
[06:39:48] ImmoveableOne: Hello, I want to process and save(to a file) the parameters to every method call I make in rails, be it in a library, helper controller or model. Is there a universal method filter or some such I can use?
[06:51:54] foreman-n00b: Hello, all! Greetings. I have some questions about `Rack::MethodOverride#call`. I googled around and have a fair idea about what's going on, but still have a few follow up questions. I jumped into this rabbit-hole because of NewRelic that told me `Rack::MethodOverride#call` consumes like 137000 ms, which is 84% of the POST call. It also accepts a tarfile anywhere between 100-250 MB. Would that be a reason that I am seeing it consume so much
[06:51:54] foreman-n00b: time, because it waits for the POST request to complete and see if there are any methods in the POST call that should override the Rack methods?
[06:57:29] michael_mbp: I'm looking for advice on managing Unicorn workers, especially in terms of running a large number.
[06:58:14] michael_mbp: Reason being, on a 32GB RAM compute instance (for example), easily 80 workers if not more could be run (using only ~18GB of RAM, so there's a lot more headroom).
[07:00:30] michael_mbp: However, this translates to 80x Postgres connections. This absolutely hammers the DB.
[07:42:20] chandru_in: When using active record, is it possible to specify the schema for each query. For example, I have a users table under N different schema, and I need to choose the schema based on a request parameter.
[08:33:54] TvL2386: hey guys, I've started a rails 5 project and I'm not interested in locales. However now I'm implementing a Mailer, the subject is set by config/locales/en.yml. Is there anyway to get around this?
[08:44:03] TvL2386: I just did `rails g mailer Bla my_action` and from the console I run `Bla.new.my_action`.... I'm getting:
[08:44:08] TvL2386: from /home/tom/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/actionview-5.1.3/lib/action_view/lookup_context.rb:206:in `normalize_name'
[10:02:21] xpl0iter: Hi I am trying to do user.update(user_params) this works. But when I try to update with duplicate data for a unique column, it rolls back. Now user.errors.messages is empty. So how do I get this error?
[10:05:46] xpl0iter: tbuehlmann_: this model has several validations, but the field I am trying to update doesn't have a validation.
[10:06:29] tbuehlmann_: rails doesn't add errors for database constraints, only for "soft" validations from your model. so just add a validation in your model
[10:07:55] xpl0iter: tbuehlmann_: oh ok. So I have to add validation for uniqueness in this case, right?
[12:27:53] Guest30814: is someone who can help me or give me a good example to export csv file model with assosiation
[12:28:37] xpl0iter: Hi I am using 2checkout sandbox to try out implementing a payment page. Now the issues is after the 2checkout payment is complete, it returns something to my application. Now if the page is refreshed the db data gets duplicated. How to avoid this?
[12:33:44] krmela: good friday evening exist something with oppositive function Offer.find_by day: day).any?
[14:10:34] mustmodify: I have the weirdest issue. An app in production runs fine for long periods... sometimes a week, sometimes a month. it is used lightly, but daily.
[14:12:01] mustmodify: And then it'll start up with "comparison of Date with ActiveSupport::TimeWithZone"
[14:12:32] mustmodify: for something like `@employee.ident_expiration_date && @employee.ident_expiration_date < 3.months.from_now`
[14:40:41] faraco: Hi guys, I have a question. I have a dilemma on using either cms or mvc/mvt/etc web framework. I did a simple blogging app with mvc framework, which I found almost useless compared to time I spent can be used on setting up cms say Wordpress for blogging. I'm not sure what is the exact applications that is suited to build on mvc framework?
[14:47:54] faraco: I didn't with rails, but I did with Perl's Mojolicious::Lite which is inspired by Sinatra and also PHP's Lumen for simple micro services.
[14:48:37] pro777: I guess for me, if I think the controller logic would fit in one file, then Sinatra is great. Otherwise I'd go with Rails. Having said that, it depends on the type of problem you are trying to solve.
[14:49:06] pro777: WordPress can be clunky, but you'd be hard pressed to write a better blogging platform from scratch in Rails in a reasonable amount of time.
[14:51:15] TvL2386: hey guys! I'm following these docs: http://guides.rubyonrails.org/action_mailer_basics.html. I'm doing `attachments.inline['logo.png'] = File.read(Rails.root.join('app','assets','images','logo.png'))` then in my haml mail view I'm using it: `= image_tag(attachments.inline['logo.png'])`. For some reason when I try to send the email, I'm getting:
[14:51:20] TvL2386: ActionView::Template::Error: The asset "Content-Type: image/png\r\nConten..........$LONG_BASE64_ENCODED_BLOB........." is not present in the asset pipeline.
[14:57:08] faraco: Pro777: Hmm, maybe my question clarified enough. Maybe what I want to ask is, what is the most probably suited type of applications to be built with mvc framework (beside social app)?
[14:59:26] pro777: faraco: I think Rails excels are making rapid prototypes of reasonably complicated apps which can be hardened to a production version without a herculean effort. Right now I'm working at a company where our main app is Rails. It's a financial company similar in some respects to the paypal button works.
[14:59:47] pro777: So the domain logic is pretty complicated, but the code is organized in such a way that it's pretty easy to maintain and customize.
[15:01:01] faraco: I see, now I can get the picture why people use MVC, like making a payment gateway or some sort. Thanks1
[15:07:31] michael_mbp: That's a good point Pro777. That 'organisation' (or convention over configuration nature) of Rails also _generally_ makes it easier for new comers to a project to easily re-familiarise themselves with a code-base they've never seen before, well usually.
[15:08:07] michael_mbp: ^^ only depends on how far a team sticks to the 'usual Rails' way, and there's a lot of reasons not to as well.
[16:57:00] cam27: Looking to add a plugin for code suggestions (intellisense) in vim. Should I want a Rails or a Ruby Plugin?
[17:08:17] IsoLinCHiP: Hi. I am trying to track a capistrano error when it runs rake assests:precompile in production. I am getting 'Sass::SyntaxError: Invalid CSS after "/": expected identifier, was "/* line 1, /srv..."' as an error but no corresponding filename. Any ideas how I could get said filename?
[17:12:38] sunya7a: hi, Is it possible to create a dropdown or radio button form element that allows a write in on an answer choice...sort of like a follow up field?
[17:16:07] vcarl: is there a way to use a default value iff the supplied value fails validation? we're importing data from a third party and are getting a handful of bad values where an empty string would be acceptable
[17:16:44] Criten: vcarl: you could have a custom validation that doesnt put any errors in the array
[17:16:50] vcarl: so i'd like to use the provided value if it validates fine, but if it doesn't i want to use an empty string
[17:18:00] Criten: But yeah, define a block for it and just do your validation + default manually in there
[17:18:03] vcarl: the data we're getting back is weirdly shaped or i'd just do that logic where we save it
[20:57:42] francuz: hello everyone, I have a model Client, a join model Registraion, and a model Session. I would like to do something like "@clients = Client.where(sessions doesn't include Session)" what would be the cleanest way to do this? (now I made a "@cleanedClients = [ ]" and a double foreach to populate this variable, but it looks horrible)