#RubyOnRails - 09 July 2016
« Back 1 day Forward 1 day »
[08:10:05] rubyonrails548: image_tag(post.image_url, width:640, fetch_format:"auto", quality: 50, class: "img-responsive")
[08:10:36] rubyonrails548: here, i've changed the quality to many different values but i'm not seeing any changes on the images on the site
[08:11:18] rubyonrails548: i tried cl_image_tag instead of just image_tag, but that isn't working either
[08:15:40] tbuehlmann: rubyonrails548: don't know Cloudinary, but the docs tell us to use cl_image_tag("sample.jpg", :width => 100, :height => 150, :crop => :fill)
[08:19:36] rubyonrails548: @tbuehlmann as in changing the quality parameter to different values doesn't affect the images' quality in the site
[08:22:32] tbuehlmann: can you check whether the url changes at all when you provide the qualit argument?
[08:28:43] tbuehlmann: before checking the source code of the gem: could you try using the key :q instead of :quality?
[10:58:56] peterppp: I'm trying to deploy my Rails app using Capistrano for the first time, but Capistrano only creates an empty directory structure without any files whatsoever. What did I do wrong?
[11:10:50] abhvl: whele trying to old object to new using .dup i get error on its .photos association that Paperclip::Errors::NotIdentifiedByImageMagickError
[11:53:59] durexlw: anyone here has experience building a modular saas app that allows users to buy modules and when they bought them, have them available in your webapp?
[12:19:55] finnnnnnnnnnn: can anyone suggest a more succinct way to make this hash? https://gist.github.com/anonymous/f2f7831fe40e4ec72ac6a584baf91341
[12:29:40] durexlw: nickjj: what did you use to declare roles? I kinda expect you need a login/authorization and way to handle certain roles for users?
[12:30:22] durexlw: Maybe if I ask the question more general: I'm looking for an architecture on how to set this up, but I don't have any experience with it, so I'm looking for some good ideas
[12:31:05] nickjj: durexlw, i tend to reach for devise/pundit to handle the combo for authentication and authorization
[12:31:34] nickjj: but if you generalize your problem, a module is just a type of content that a user conditionally has access to
[12:32:00] nickjj: and that access is going to be based on them having some type of transaction ID saved to a db for that module
[12:33:35] durexlw: yeah, I guess I'm still trying to make a mental picture in my head about that. basicly, what I want to do is: a website, one central login system, users can unlock modules that then become available in the site to them. Let's say we forget payment for a sec, how would you go about this problem, design wise?
[12:33:46] nickjj: implementation wise, it's not really different than restricting someone from only being able to view their own todo list
[12:34:13] nickjj: except instead of restricting it on user_id, you'd restrict it on that along with a transaction id of some sort
[12:35:09] durexlw: makes perfect sense... what you're saying is: a module is unlocked, the combination of this unlock-key and the user being logged in, is what makes the module accesible
[12:37:20] nickjj: if you wanted to eliminate the payment aspect but still wanted to tie it into an action, you could just email them a link, and when they click the link you'd save a random token to the db -- and that kind of mocks the payment
[12:38:05] skroon: is there a way to disable paperclip to do url/file checking on remote host? it slows down my site a lot
[12:38:30] nickjj: durexlw, role details would be handled by pundit, i recommend checking their readme since they have examples
[12:39:31] durexlw: I certainly will nickjj, I'm still a bit wondering: roles seem to be things that are used 'inside' the modules, not so much for unlocking them, would you agree?
[12:39:32] nickjj: basically you'd create a policy that says "this user must have something saved in his records that shows he purchased the module", and then you'd just protect your modules controller actions with this authorization policy
[12:42:59] durexlw: so you're saying don't think about roles for unlocking modules. Unlocking modules is about what you can access, whereas a role is about who you are when granted that access?
[12:45:27] nickjj: even if you decided to make a role out of each module, you'd still want to use pundit to do the authorization of it
[12:46:36] durexlw: nickjj: but if I understand correctly, from your experience you'd adise against making a role for a module, right? Or am I understanding you wrong?
[12:47:35] nickjj: durexlw, it wouldn't be a terrible idea -- in my cases i've only built systems where there was 1 module to be bought
[12:47:50] durexlw: Currently I have a User that has_many activations and an activation has_many modules. So an activation ties a user to a module. The activation between a module and a user is created when provided the correct unlock-code
[12:49:19] nickjj: i'd imagine the auth on a role based module would be as simple as: current_user.roles.include? 'foo_module'
[12:49:28] durexlw: this works fine, but this is because a module is currently more a group of articles. So it were as if your example: a user can only but one (kind) of module
[12:50:22] durexlw: but like you say: when there would be different kind of modules, I'm kinda guessing this would become a mess, and the suggestion of making each module a role, would clean this mess up quite a lot and make it more managable
[12:51:50] durexlw: I really appreciate your time and help, nickjj. I think this exchange has brought a lot of clarity and saved me a bunch of headache down the road, so thanks
[12:54:18] skroon: durexlw: paperclip, is doing a check if the file exists before rendering the URL, but if you have images not on local filesystem but on S3 of Google Cloud, this because a *really* slow process for large collection of files
[12:55:48] durexlw: nickjj: cool... I'm kinda making a site for that. I give real life classes, but I get a lot of questions, so I'm building something that people can register for the online equivalent of the aqtual course, so that I can capture there questions there and they can find the documentation for the course they followed all in one organised place
[12:57:34] nickjj: for example, one of them goes into learning about docker and how to scale a load balanced rails app on AWS with docker
[12:59:02] peterppp: I just found capistrano-ssh-doctor, and claims that SSH agent forwarding is set up correctly, but when I try to deploy I still end up with an empty directory structure
[12:59:34] durexlw: nickjj: if you'd be interested, we could pair up... I'm not in it for the money, so it might be a good deal for you. And I'm mainly happy if people find what they're looking for
[12:59:43] peterppp: I feel pretty dumb and if someone could point me in the right direction, I'd be very grateful
[13:00:13] nickjj: durexlw, course hosting platforms are a tricky thing to do well but sure we can talk more about it
[13:06:24] passbe: I'm trying to use store_accessor to expose keys within a jsonb postgres column like this: http://nandovieira.com/using-postgresql-and-jsonb-with-ruby-on-rails. But with Rails 5 im getting: ArgumentError: wrong number of arguments (given 3, expected 1..2) anyone aware of changes to serialization that may affect this?
[13:09:46] matthewd: passbe: I believe jsonb should work the same as json: http://guides.rubyonrails.org/active_record_postgresql.html#json
[13:10:07] passbe: oh jesus, turns out you can't serialize more than one field. ie: serialize :field, :field JSON
[13:11:06] matthewd: peterppp: I don't know much about capistrano, but I doubt anyone can help you without any indication of what you're doing
[13:13:27] peterppp: matthewd, thanks for your response, I'm trying to follow the tutorial on how to deploy a Rails app from gorails.com
[13:14:27] gerep: Can someone please help me understand why my message in the block comes as nil? I'm using aasm to manage the object states: https://gist.github.com/gerep/078dea8152ea62d6862dc5df121a22bb
[13:14:45] gerep: After the read event I need to update the read_at (datetime) column in my message object
[13:16:52] matthewd: peterppp: !gist your capfile (and the terminal session of you running it, I guess)
[13:16:52] helpa: peterppp: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[13:37:17] PotatoChipz: Hello. I am trying to add a new DSL to Grape API. And I just added a new class in lib/grape/dsl directory. But.. I cannot make it work.
[13:37:53] Fernando-Basso: When I create a new rails app, is it possible to have rails installed in vendor/ ? (I use rvm, if that matters)
[13:38:59] pontiki: Fernando-Basso: if you use --skip-bundle on the rails new command, you can run bundle later telling it to go into vendor
[13:44:14] Fernando-Basso: rails new testapp; cd !$; bundle install and vendor/ only has the assets dir. Perhaps my bashrc is the culprit, since it is setting GEM_HOME
[13:48:22] gerep: I have a controller archive methods called via PUT and my test is checking if a state of my message object has changed: https://gist.github.com/gerep/3f6a2f15594b7d06fd5da73f51731ce5
[13:48:49] gerep: I don't know why in my tests, after the controller archive methods is called it is still maintaining the old state "unread"
[13:49:25] gerep: Debugging the controller I can see that before the @message.archive method is called, the state is "unread" and after it is "archived" as expected but in my unit test it is not working
[13:49:50] gerep: The same debug shows that in my unit test the @message.state is always "unread", before and after the PUT call
[13:51:09] matthewd: Fernando-Basso: Note that the Gemfile.lock is intended to deal with the problem of keeping Rails (etc) versions in sync with the code in your repository... depending on exactly what problem you're trying to solve, you may not actually need to vendor the full gem contents
[13:52:16] Fernando-Basso: matthewd: I am trying to have gems and rails itself indexed in my tags file.
[13:55:49] matthewd: Fernando-Basso: I haven't tried it, but https://coderwall.com/p/modh-g/ctags-bundler-vim-exuberance may interest you
[14:12:27] pontiki: (which might be entirely due to the having spent so much time figuring it out, not that it's better)
[14:13:43] gerep: pontiki: maybe you can help me with another issue? https://gist.github.com/gerep/3f6a2f15594b7d06fd5da73f51731ce5#file-message-rb I need to save the message date when a state is called but my test shows that the archived_at column is nil
[14:21:12] gerep: matthewd: sure, that's an option...another option was doing this: https://gist.github.com/gerep/3f6a2f15594b7d06fd5da73f51731ce5#file-message-rb
[14:21:20] gerep: pontiki: take a look: https://gist.github.com/gerep/3f6a2f15594b7d06fd5da73f51731ce5#file-message-rb hahahaha
[14:24:58] peterppp: for a few hours I've been trying to deploy a Rails app using Capistrano so far unsuccessfully, here's a gist with my deploy.rb and the output of capistrano: https://gist.github.com/anonymous/30f2d6f8ffed3620b721fab2e7bee03e
[14:28:07] peterppp: ... had to do it again: https://gist.github.com/anonymous/a50b9f05af52d56b3de4257d71107c36
[14:33:23] fryguy: the cap file says it deploys to /home/me/myapp but logs reference /home/peter/myapp
[14:33:29] peterppp: in my gist? if so, that's because I replaced a couple strings perhaps inconsistently
[14:33:44] helpa: Please do not use fake values, as they can be confusing or misleading. Sometimes both.
[14:34:05] pontiki: peterppp: include your deploy/*.rb files. only instead of making one HUGE text file, add files individually
[14:35:09] helpa: How to use Gist properly: https://github.com/radar/guides/blob/master/using-gist.markdown
[15:04:34] rubyonrails132: I'm trying to render a partial (_view.html.haml) from PostsController in a view inside ProfilesController
[15:04:45] rubyonrails132: I tried = render partial: '/posts/view' but I'm getting a missing template error
[15:05:19] rubyonrails132: The error goes like "Missing partial profiles/_post, application/_post... "
[15:07:20] mustmodify_: When deploying my monolith, I got "Deadlock found when trying to get lock ...." for an update statement. I assume it happened while I was migrating that table to add a column. Is this avoidable? Or just something you live with?
[17:03:45] ia9371: I mean its on github looks like all the versions are the same. I copy and paste the entire contents but of course this doesnt work so im trying to think of the most efficient way of get this to work
[17:04:41] ia9371: pretty much I should just need to copy the app folder and than edit some config settings right?
[17:21:21] mustmodify_: ia9371: So just to verify... you have your code on github. And you have a server. And you want to know how to get your code from github to your server?
[18:12:31] ia9371: and than i try to install them and it says that unable to install, im using gatorhost
[18:18:35] ia9371: well i was trying gatorhost and it has been giving me issues I may change hosts soon
[18:19:23] ia9371: its been a while since I have used rails but I am having a lot of trouble just getting the database to migrate
[19:28:32] Fernando-Basso: I am in admin/posts, but controller_name returns just 'posts'. Is that correct?
[19:31:07] Moeh: Hey guys, is there a way to get a erb file in a controller as string? (would like to convert to PDF)
[19:31:22] Moeh: I tried using render:, but rails complains that I cannot use multiple renders in one action
[20:43:31] ia9371: when I rails generate controller Welcome index it generates some files but it doesnt generate the welcome and index controller and view
[20:54:07] Fernando-Basso: For some reason, db ids are very high, something like 590023556 in an app I just started developing. Is that something new with rails 5?
[20:54:31] ia9371: im following the easy tutorial online and rails rake db:migrate works but when I do rails generate controller Welcome index it generates a bunch of stuff but it doesnt actually make the controller or the view
[21:04:41] art-solopov: tweeeaks: I've seen a job vacancy from a company stating they use Rails 5. I wonder if I should look into their eyes.
[21:19:44] alex88: hi there, if I have a DataChannel, to broadcast to every connected user, is ActionCable.server.broadcast('data', ....) enough? I doesn't seems to receive any message client side
[21:22:54] alex88: even in development? I thought that with 1 server everything can be done within the app server
[21:25:34] ia9371: anyone have experience with cpanel settings making website show up as index of files
[21:29:22] Fernando-Basso: Perhaps I could empty every row in the db/tables and do something like alter sequence foo_id_seq restart with 1
[21:33:52] art-solopov: Fernando-Basso: Fixtures tend to use some sort of generated ids which can be gigantic.
[21:41:45] Markhor1991: i meant, is it worth learning 5's uniqueness and features instead of only 4's
[21:54:19] Fernando-Basso: art-solopov: Yes, that was the problem. I had the test db accidentaly set to the devel db when ran some tests. I cleared all tables, restarted all id sequenses to 1, and now I get ids like 1, 2, etc.
[22:05:21] naftilos76: Is there a way to prevent a specific css file from loading by entering some kind of exception in application.css ?
[22:10:06] ia9371: i can see the index file but I change that to indexOld.html and try to configure routes
[22:18:35] businessgeek: hi all. I have a brief question regarding rails 4.2 to 5 upgrade. I am just working on the upgrade and i observed a different behaviour during navigating between different pages. sometimes elements which changed some clicks before are loaded again. the loading indicator seems also to be much more active then before. in addition, on my dashboard done with chart.js i can see that the charts are loaded 2 times sometimes. are this al
[23:08:08] ia9371: can someone tell me how your suppose to do this routes file http://pastie.org/10903016
[23:39:42] fredolinhares: Why ActionController::Base have authenticate_with_http_basic and ActionController::API don't?
[23:52:45] fryguy: ia9371: i doubt anybody here has any idea how to get rails to run in a FastCGI type environment