#RubyOnRails - 24 February 2018
« Back 1 day Forward 1 day »
[12:55:34] digitalowl: Hello, guys. Can you tell me about bootstrap-sass using? I do all from instruction on github, but assets:precompile faile with 'bootstrap-sprockets' with type 'style' not found. When I looking for files in gem directory I found files _bootstrap.scss and _bootstrap-sprockets.scss. I use rails 5.
[12:56:32] digitalowl: I try include bootstrap libraries in application.css.scss like /*= require bootstrap-sprockets /*= require bootstrap /*= require_self
[17:13:28] garyserj: is there a form helper that creates a button element rather than an <input type...> because my buttons have text that is quite explanatory like "create new user" and I want that displayed on the button but I don't want it sent to the server. The button element allows the value to be distinct from what is displayed on the button
[17:22:05] mroutis: garyserj: if you are inside a form, typing `f.button` will create a button of `type=submit`, if I understand your question, you don't want to "submit" your form using that button, however I don't get why "creating a user" would not reach the server, can you help me more to understand what you are trying to achieve?
[17:24:54] mroutis: garyserj: here's the source, if you're interested in how does this "helpers" do their magick: https://github.com/rails/rails/blob/bdc581616b760d1e2be3795c6f0f3ab4b1e125a5/actionview/lib/action_view/helpers/form_helper.rb#L2259-L2263
[17:25:08] mroutis: garyserj: https://github.com/rails/rails/blob/bdc581616b760d1e2be3795c6f0f3ab4b1e125a5/actionview/lib/action_view/helpers/form_helper.rb#L2274-L2290
[17:27:01] mroutis: garyserj: so, if you only want to display a button without any actions, you could use the `button_tag` with type `button` as described here: http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-button_tag
[17:29:05] mroutis: garyserj: I haven't tried it, but by reading the source, I guess is also possible to do `f.button type: 'button'`
[17:38:41] crst: Hi, I'm trying to upgrade 4.2 -> 5.1. Added gem 'rails', '5.1.5'. But when I run bundle update rails I get: The bundle currently has rails locked at 4.2.10. Try running `bundle update rails`
[17:42:30] mroutis: crst: it's not a good advise (I don't understand why running `bundle update rails` is not working), but you could always remove your Gemfile.lock to update everything; however, this will probably break some stuff (if your Gemfile is not versioned enough)
[17:43:42] crst: mroutis: It's so strange, isn't it? I've been avoiding deleting Gemfile.lock since I run into multiple issues when I did.
[17:44:48] mroutis: yeah, I can't help you that much; are you using a ruby environment manager? (as rbenv)
[17:51:54] mroutis: crst: ^ using a gist, hehe, maybe you are using an engine that requires rails 4, I really don't know
[17:53:34] crst: lol, now when I bundle install after removal of Gemfile.lock I get: Could not find gem 'rails (= 5.1.5)' in any of the gem sources listed in your Gemfile.
[18:01:38] crst: wait, I've got it. It's been either rbenv-bundle-exec or rbenv-binstubs which caused that. Good riddance.
[18:40:16] maesitos: Hello I'm trying to run a code before initialisation in a Rails generator I'm developing, any help?
[18:47:57] maesitos: basically, what I need is to run a script after the configuration from my gem has been loaded
[18:49:14] mroutis: maesitos: and it's part of your "generator"? why don't you offer an `init` task, as devise does
[18:50:19] maesitos: I'm pretty new to rails and the convention over configuration and the load process is a bit of a puzzle
[18:53:09] maesitos: Basically it's a gem that provides multiple adaptors for different APIs. So the gem users defines the adaptor he'd like to use in /config/initializers/gem_name.rb
[18:53:45] maesitos: and I'd like to have a singleton class that includes an instance for that generator, the one provided by the gem user
[19:05:53] mroutis: maesitos: so, you are writing a gem, and when the user includes the gem to his/her Rails app, you want them to configure it through an initializer, right?
[19:06:34] maesitos: that gem needs to post some things based on that configuration to a server just once
[19:07:03] maesitos: in fact it posts the URLs for a web-hook so I'd also need ActionDispatch loaded
[19:08:52] mroutis: maesitos: I haven't done it before, but try to take a look into rollbar's gem https://github.com/rollbar/rollbar-gem
[19:19:06] garyserj: I understand the concept of loops. But I don't understand how rails processes this. Given this code in a rails template.. https://gist.githubusercontent.com/anonymous/f6c88140bc0d86fa17963b91cc619935/raw/68b6180b0570305c8e88ac307d15c6c96daf7a01/gistfile1.txt what does Rails do with it?
[19:48:47] garyserj: It seems like the rails interpreter is saying Read line 1, execute it. Line 2, execute @a.each then it sees the 'do' so it sees a block is being apssed in, then it sees |x| which is still ruby code, then you get this interspersing of html to display, and ruby code to run. And some code will return html which is displayed. What exactly is the rails interpreter doing to deal with that?
[19:49:59] fryguy: garyserj: what you are looking at isn't ruby, it's erb, it runs through a preprocessor first
[19:53:47] garyserj: ah so it's not ruby and it's not rails, it's erb.. so I guess I want to know what the erb preprocessor is doing.
[20:10:19] garyserj: If I want more text in my form's submit button than just one word, e.g. <%= submit_tag("create new user") %> Then ideally i'd want just the name value pair of commit=createuser to be sent to the server, and the text of "create new user" to be displayed on the button. But what I get is something like commit="create+new+user" which is a bit laborious. What method would you suggest to
[20:10:19] garyserj: get a smaller value sent to the server while still having the longer description as text on the button?
[23:08:05] mroutis: for example, thoughtbot's suspenders https://github.com/thoughtbot/suspenders (well, technically not a template, but you get the idea)