Activity Graph

Page 1 of 5 | Next »


[08:32:40] NL3limin4t0r: ZAJDAN: SQLite is mainly used to quickly setup an development environment, prove of concept or minimum viable product. It's not a serious option to considder when shipping a product.
[09:17:06] NL3limin4t0r: ZAJDAN: Most databases allow you to export to an SQL file. This can be converted by using a tool (for example
[09:19:12] NL3limin4t0r: ZAJDAN: RebaseData also allows you to provide an .sqlite .sqlite3 .sqlitedb or .db file directly as input.
[11:29:55] NL3limin4t0r: ZAJDAN: Table names are the plural form by default. eg. the table `posts` for the model `Post`.
[11:32:19] NL3limin4t0r: ZAJDAN: Try scaffolding a model and have a look at the output files. `bundle exec rails generate scaffold Post title:string body:text`
[11:33:11] NL3limin4t0r: You can reverse the effect by changing "generate" into "destroy".
[11:34:49] NL3limin4t0r:
[11:40:03] NL3limin4t0r: sevenseacat: The question was "is any convention for Database name?" so I'm not supprised by your answer.
[14:38:23] NL3limin4t0r: cek: No. Assuming you mean like JavaScript `{ a, b }`
[14:41:03] NL3limin4t0r: Imo they still miss a lot of features. Like zipping arrays together or having a decent group_by/unique methods.
[14:43:44] NL3limin4t0r: But it's getting better each update.
[14:47:41] NL3limin4t0r: ZAJDAN: You can connect to different databases for different model.
[14:51:55] NL3limin4t0r: Cork: I've never needed it, but you could try `t.references :table_that_is_quite_long, foreign_key: {name: 'your_fk_name'}`
[14:53:44] NL3limin4t0r: Cork: Why not? I've done `t.references :some_attribute, index: {unique: true}, foreign_key: true, null: false` quite often.
[14:54:21] NL3limin4t0r: ^ "you can't combine index: and foreign_key"
[14:58:21] NL3limin4t0r: Strange, normaly it simpy would add the constraint to the "create table" statement and not run an "alter table add constraint" statement.
[15:04:51] NL3limin4t0r: Cork: What RoR version are you running? Adding options to the foreign_key option should be possible.
[15:06:28] NL3limin4t0r: RoR 5.2.3 does extract options
[15:06:33] NL3limin4t0r:
[15:17:13] NL3limin4t0r: I have to go home. I'm on bike and if I don't go home before the storm hits I'm the remainder of the evening in office. Having `add_foreign_key` in a seperate statement is not the end of the world.


[12:03:48] NL3limin4t0r: Quit: WeeChat 1.9.1
[13:55:52] NL3limin4t0r: has joined #ruby
[13:55:58] NL3limin4t0r: has joined #RubyOnRails
[16:01:06] NL3limin4t0r: kalib: What variable name correspond to what you call "servers". There is no mention of any "server" in your code sample. Since you're adding the `role` to the `regions` array can I assume that's what you mean?
[17:30:52] NL3limin4t0r: &>> require 'ostruct'; module Enumerable; def _map(&block); map { |obj| obj.instance_eval(&block) }; end; end; [{name: 'Jarmen Kell', age: 36}, {name: 'Black Lotus', age: 25}, {name: 'Colonel Burton', age: 29}].map(&OpenStruct.method(:new))._map{ "#{name} is #{age} years old"}
[17:37:15] NL3limin4t0r: nate-^ is already gone, but it's easy to remember if you know that I18n stands for Internationalization the 18 stands for the 18 characters between the I and n.
[17:40:48] NL3limin4t0r: Net: Model.where(bar: $2).or(baz: $3).where(foo: $1)
[17:41:07] NL3limin4t0r: Net: Model.where(bar: $2).or(Model.where(baz: $3)).where(foo: $1)
[17:41:12] NL3limin4t0r: First one is invalid
[17:44:03] NL3limin4t0r: Net: RoR wraps a lot of parenthesis in SQL statements. But `Model.where(bar: $2).or(Model.where(baz: $3))` will for sure be wrapped with parenthesis.
[17:44:54] NL3limin4t0r: The alternative is `Model.where(foo: $1, bar: $2).or(Model.where(foo: $1, baz: $3))`
[17:45:21] NL3limin4t0r: But with the above you have `foo = $1` two times in the query.
[17:46:58] NL3limin4t0r: Net: Just the first. You could do `@company.where(bar: $2).or(@company.where(baz: $3))` to get what you want.
[17:49:35] NL3limin4t0r: Yeah, it's not the cleanest solution.
[17:50:27] NL3limin4t0r: I prefer to shove the `or` statements as in the front as possible. Otherwise the where statement might end up with lots of duplication.
[17:50:39] NL3limin4t0r: ^ The SQL output I mean
[17:54:41] NL3limin4t0r: Net: You could also opt for an arel solution: `.where(foo: $1).where(Model.arel_table[:bar].eq($2).or(Model.arel_table[:baz].eq($3)))` which results in cleaner SQL but more cluttered Ruby.
[17:56:38] NL3limin4t0r: Of cource, when using arel you mostly assign `Model.arel_table` to a variable first, to shorten the whole thing and make it more readable.
[17:58:35] NL3limin4t0r: eg. `ct = Company.arel_table; @company.where(foo: $1).where(ct[:bar].eq($2).or(ct[:baz].eq($3)))` where `ct` stands for "company table".
[18:01:54] NL3limin4t0r: `eq` stands of couse for `equals`, but you can also use other operators that are normally not allowed in simple `where` statemts. Like `gt` or `lt` (greater than and less then respectively) and a whole bunch more.
[18:01:56] NL3limin4t0r:
[18:41:29] NL3limin4t0r: Momentum: Bundler is project specific. I assume you ran it in the past in the current project. Btw the reason it's not in the Gemfile is becouse it's part of the Ruby standard library. So it should come with the Ruby installation.
[18:44:22] NL3limin4t0r: irb should be installed upon installing Ruby. what is the output of `ruby --version`? and does `irb` (the command) work in your terminal?
[18:48:47] NL3limin4t0r: railsnoob: You could use a multi-select. Add the `multiple: true` option to the helper you're using. eg. `, options, multiple: true)` or `select_tag(:name, options, multiple: true)`.
[18:49:16] NL3limin4t0r: ^ With `options` I mean select options.
[18:52:47] NL3limin4t0r: The multi-select is pretty ugly, but you can make it more usable with for example the `chosen-rails` gem (Or any other gem that makes multi-selects more usable.)
[18:53:22] NL3limin4t0r: railsnoob: That should be: <%= :tags, $array, {multiple: true}, {class: "input dropdown"} %>
[18:55:04] NL3limin4t0r: If I'm not mistaken "multiple" is a rails option.
[18:55:21] NL3limin4t0r: railsnoob: The data is send to the controller. How it is saved depends on how you handle it there.
[18:56:25] NL3limin4t0r: Momentum: Weird going on. What is the error you're getting when you try to run `bundle exec rails console` ?
[18:56:39] NL3limin4t0r: Nothing* weird
[19:01:29] NL3limin4t0r: railsnoob: To save an array as attribute you have to set the database column to `text` and serialize it in the model. Check out
[19:03:02] NL3limin4t0r: railsnoob: eg. something like this in your model `serialize :your_attribute, Array`
[19:07:49] NL3limin4t0r: Momentum: I personally haven't really encountered that error before. Have you tried reinstalling Ruby? If you're running rvm you can simply `rvm reinstall 2.6.3` (the version should be changed to what you use.)
[19:12:09] NL3limin4t0r: Momentum: If you're running ruby from the distro-repo you might only have installed the runtime environment. In that case you could try and install the `Ruby-irb` package (you say you spotted), but for development you normally install `ruby-dev`.
[19:13:03] NL3limin4t0r: Inside: You can run the two together without issue. As long as you're not trying to do both in one file.
[19:14:27] NL3limin4t0r: eg. `some_view.html.haml.erb` is most likely not going to work. But you can have some files with the .haml extention and some files with the .erb extention.
[19:17:29] NL3limin4t0r: Iarfen: Assuming you mean the `spec` directory I have no clue. If you're running version control you can simply delete the folder, check what happens and revert.
[19:17:48] NL3limin4t0r: Iarfen: If you're not using rspec the directory isn't used anyway.
[19:20:58] NL3limin4t0r: ACTION realizes it's getting late.
[19:23:35] NL3limin4t0r: Momentum: Try to see if you can find the `ruby-dev` package (I don't know if it's named differently under Arch). Otherwise try to install ruby using rvm ( or rbenv (


[07:29:31] NL3limin4t0r: MrCrackPotBuilde: I don't have a lot of experience using active storage, but from a plain RoR perspective it looks fine.
[08:43:25] NL3limin4t0r: baweaver: You could also use the coposition operator as pipe.
[08:43:50] NL3limin4t0r: baweaver: You could also use the coposition operator as pipe.
[08:44:13] NL3limin4t0r: oops, double message
[08:45:14] NL3limin4t0r: &>> double = ->(n) { n * 2 }; increment = ->(n) { n + 1 }; (double >> double >> increment >> double).call(5)
[08:50:46] NL3limin4t0r: &>> double = ->(n) { n * 2 }; increment = ->(n) { n + 1 }; 5.then(& double >> double >> increment >> double)
[09:22:32] NL3limin4t0r: ZAJDAN: In RoR context parameters mostly refers to `params` in the controller. Whereas arguments are simply values passed to a method.
[09:45:35] NL3limin4t0r: ZAJDAN: `params` is only avaible in the controller, views and the view helpers. If you need the value of an parameter in the controller you should pass it as an argument.
[09:47:22] NL3limin4t0r: For example let's say I have the scope `scope color, ->(color) { where(color: color) }` in the controller I can do `Bike.color(params[:color])` (assuming the color parameter is present).
[09:51:13] NL3limin4t0r: So you should ask yourself, why do you need to access the request parameters in the model at all?
[11:00:48] NL3limin4t0r: ZAJDAN: In the controller you do `params.try(:commission).try(:kw)` which would be similar to `` which is not what you want.
[11:02:37] NL3limin4t0r: ZAJDAN: That should be `params[:commission][:kw]` or `params.require(:commission).require(:kw)` or `params.dig(:commission, :kw)`.
[11:04:17] NL3limin4t0r: `params.commission` doesn't exists and would normaly raise a NoMethod exception, so `params.try(:commission)` will always return `nil`.
[11:41:46] NL3limin4t0r: ZAJDAN: You can still do so `kw = params.dig(:commission, :kw); if kw; ... else; ... end`
[11:59:08] NL3limin4t0r: If you use `require` you can assume that the parameters are provided. Otherwise a ActionController::ParameterMissing exception will be raised.
[12:25:43] NL3limin4t0r: From you other link ( it seems that you don't submit the parameter in nested context. You should simply use `params.require(:kq)` or `params[:kw]`.
[12:26:03] NL3limin4t0r: Or change the view to match the expected structure.
[13:58:04] NL3limin4t0r: ¯\_(ツ)_/¯
[15:37:37] NL3limin4t0r: Inside: Errors or warnings? Deprecation warnings aren't errors.
[15:38:49] NL3limin4t0r: The largest issue I faced upgrading 5.1 to 5.2 was the fact that the `attribute_changed?`, `attribute_was` and `changes` behave differently after save.
[15:40:34] NL3limin4t0r: They are now `saved_changes_to_attribute?`, `attribute_before_last_save` and `saved_changes` respectively.
[15:44:57] NL3limin4t0r: yoshie902a: What is the usage of the instances of the model? "associationed with my Form Form Dropdowns checkboxes, mult-selects" isn't really specific. Are they used to build the form elements?
[16:52:54] NL3limin4t0r: yoshie902a: If they're all form helpers. I would say go for something like FormHelper::Dropdown::Car or FormHelper::Collection::Car
[16:55:46] NL3limin4t0r: FormCollection ?
[16:57:30] NL3limin4t0r: I just saw you already proposed that name before. But I'll have a quick look for you in their source about plural or sigular form.
[17:01:12] NL3limin4t0r: Rails mostly uses plural form. eg. ActiveRecord::Associations::Association, ActiveRecord::Associaions::HasManyAssociation, ActiveRecord::Validations::Presence, etc.
[17:09:00] NL3limin4t0r: ZAJDAN: Rails works pretty simple. A request comes in at a sertain url, that url will be handled by a certain controller (visible through `bundle exec rails routes`). The action that handles the request sets the instance variables that carry over to the view. If no view is specified the default view is used (for users#index (UsersController) that would be views/users/index).
[17:10:57] NL3limin4t0r: ZAJDAN: Instance variables (@some_name) also carry over to partial, but I would reccomend against the use of those variables there. Instead pass the instance variables as locals, so you can use other names in other controller actions.
[17:12:20] NL3limin4t0r: ZAJDAN: When rendering a partial use something like (users#index) `render 'users/user_table', users: @users`.
[17:13:35] NL3limin4t0r: ^ The above should be in the view. When using ERB this would become `<%= render 'users/user_table', users: @users %>`
[17:16:05] NL3limin4t0r: I mostly use the checkmark (✓) for booleans. `<%= '✓' if instance.your_boolean_attribute %>`
[17:16:53] NL3limin4t0r: But you can use 1 and 0 if you like. `<%= instance.your_boolean_attribute ? 1 : 0 %>`
[17:19:39] NL3limin4t0r: ACTION looks curious in the direction of Inside
[17:24:44] NL3limin4t0r: Assuming that you have `instance` in the whole view, yes.
[17:26:26] NL3limin4t0r: You mustn't take the `instance` literal. Replace it with your variable.
[17:27:04] NL3limin4t0r: For example `<%= '✓' if @commission.cad %>`
[17:28:38] NL3limin4t0r: Sort of, all truthy values will output the checkmark while falsy values won't output anything.
[17:31:54] NL3limin4t0r: ZAJDAN: You're calling it upon a collection. It seems like you @commission accually holds multiple commissions.
[17:32:33] NL3limin4t0r: Loop though them and handle them one by one, or make sure you have a single instance to start with.
[17:33:31] NL3limin4t0r: In that case you should do `<%= '✓' if kw.cad %>` inside the #each block.
[17:45:58] NL3limin4t0r: fyber: Maybe less easy, but you could use your own (or digital oceans) server in combination with capistrano. I've not mutch experience with the setup (that's done by somebody else) but I simply type `cap production deploy` to deploy the application.
[17:49:16] NL3limin4t0r: fyber: The setup is definitly not the "easiest way to deploy rails apps", but re-deploying is pretty easy.
[17:52:00] NL3limin4t0r: ZAJDAN: I was about to say. You'll have to place the ERB code in the right spot.
[17:55:40] NL3limin4t0r: fyber:
[17:56:38] NL3limin4t0r: fyber:
[17:58:10] NL3limin4t0r: ACTION looks at the time and realizes he has to go


[10:21:50] NL3limin4t0r: MrCrackPotBuilde: How do you upload the image via postman? I assume you've converted your image into a base64 string and added that to the JSON payload.
[10:22:12] NL3limin4t0r: Using something like
[10:26:10] NL3limin4t0r: Scrap the above link, here is a better variant.
[11:17:10] NL3limin4t0r: MrCrackPotBuilde: You're missing the type declaration. Check my previous link and copy the "Base64 Image source". This should start with something like "data:image/png;base64," followed by the actual data.
[11:18:28] NL3limin4t0r: You can test if it works by simply copying the string into the URL bar of your webbrowser. If all is correct the image should be displayed.
[13:01:45] NL3limin4t0r: MrCrackPotBuilde: I suggest capturing the request made by the form and compare it to the one you make using postman.
[13:02:28] NL3limin4t0r: I also found this SO question, which might be usefull
[13:50:28] NL3limin4t0r: &>> [[:gcd, 60], :to_s].map { |method, *args| ->(value) { value.public_send(method, *args) } }.reduce(:>>).call(36)
[16:10:45] NL3limin4t0r: vdl: The hate is undeserved. The `and` and `or` operators have their place. For example `some_variable = some_method or return`. This would otherwise be written as `(some_variable = some_method) || return` or as `return unless (some_variable = some_method)` which are both pretty ugly.
[16:17:03] NL3limin4t0r: ule: The builder pattern might indeed be a good fit. You could also considder wraping the other class with an adapter, that handles the data transformation. That way you can simply provide an instance of you model.
[16:22:08] NL3limin4t0r: vdl: Different tools are for different needs. As long as you understand that and/or have lower precedence than most other operators you're good to go. It's the same as saying that two wranches of different sizes are both wrenches, so therefor you should make them the same size.
[16:29:59] NL3limin4t0r: fyber: Although RoR uses a static value for the months. They simply take 1/12 of a year. `3.months` translates to 3/12 of a year. Whith the year being `365.2425` days.
[16:31:02] NL3limin4t0r: Which is pretty logical since nowhere is specified what months we're talking about.
[16:31:56] NL3limin4t0r:
[16:36:46] NL3limin4t0r: ule: The builder pattern is meant to have a more customizable output than the factory method or abstract factory. But it deepends on your needs.
[16:37:07] NL3limin4t0r: ule:


[10:07:54] NL3limin4t0r: xco: If you don't mind returning the value of `do_something!` you can do `return do_something! if something?`. Alternatively if you really want a oneliner and you know the result of `do_something!` is always truthy you can do `do_something! and return if something?`. You could also stick the contents in a helper `def validate_something; return true unless something?; do_something!; false; end` then `return
[10:07:56] NL3limin4t0r: unless validate_something`.
[10:29:31] NL3limin4t0r: Quit: WeeChat 1.9.1
[10:31:42] NL3limin4t0r: has joined #ruby
[11:47:51] NL3limin4t0r: My guess is that it should be `belongs_to :user, foreign_key: :whodunnit, primary_key: :username`.
[11:48:33] NL3limin4t0r: or :email, depending on what is present in the :whodunnit column
[11:54:34] NL3limin4t0r: What expression returns the id from the table user?
[11:57:32] NL3limin4t0r: The `paper_trail` documentation states:
[11:57:36] NL3limin4t0r: > v.whodunnit # ID of `current_user`. Requires `set_paper_trail_whodunnit` callback.
[11:59:38] NL3limin4t0r: The simple option is to use what you already had `belongs_to :user, foreign_key: :whodunnit`. Then use `<%= %>` to access the data.
[12:04:56] NL3limin4t0r: Did you set back the `belongs_to` relation like stated in my previous message? If so check the version causing the issue has a whodunnit value set. You may need the surround the statement by `<% if version.user %>` to check for the presence of the user.
[12:08:10] NL3limin4t0r: Has the `version` a valid `whodunnit` attribute with an ID of an existing user?
[12:14:52] NL3limin4t0r: It may be caused by the fact that one of the versions you're trying to display doesn't have a `whodunnit` attribute.
[12:15:14] NL3limin4t0r: Try the following in the console: `PaperTrail::Version.where.not(whodunnit: User.pluck(:id)).or(PaperTrail::Version.where(whodunnit: nil)).count`
[12:21:08] NL3limin4t0r: Hmmm, that should work than. There might still be something wrong with the association. Check the query that's executed when you call `version.user`.
[12:33:46] NL3limin4t0r: Seems like the :primary_key option is still active. It shouldn't search through the email column of user. That's why it can't find the user.
[12:34:56] NL3limin4t0r: Double check your association and maybe restart the server.
[12:35:13] NL3limin4t0r: Maybe because the trailing comma left.
[12:35:54] NL3limin4t0r: You said you had `belongs_to :user, foreign_key: :whodunnit, #primary_key: :email`, which has a trailing comma which isn't commented out.
[12:36:26] NL3limin4t0r: Maybe it's simply a server restart.
[12:50:20] NL3limin4t0r: What is the location of #info_for_paper_trail?
[12:51:12] NL3limin4t0r: Did you define it in a model, controller, etc?
[12:52:39] NL3limin4t0r: Maybe an obvious question, but is `@localip = params[:localIP]` called before `info_for_paper_trail`?
[13:00:56] NL3limin4t0r: Looking through the paper_trail code it seems like :info_for_paper_trail is called in a `before_action` callback.
[13:01:11] NL3limin4t0r: Meaning that it will be called first.
[13:01:13] NL3limin4t0r:
[13:05:24] NL3limin4t0r: It's a bit clunky, but you could use `prepend_before_action { @localip = params[:localIP] }` to get it before the paper_trail callback.
[13:06:20] NL3limin4t0r: Alternatively simply did what you already had done, then call `set_paper_trail_controller_info` manually after you've set the variables.
[13:07:31] NL3limin4t0r: Eg. `@localip = params[:localIP]` followed by `set_paper_trail_controller_info` the next line.
[13:09:05] NL3limin4t0r: If you use the `prepend_before_action` approach, make sure you specify the action to whom it should apply.
[13:09:37] NL3limin4t0r: prepend_before_action only: :update { @localip = params[:localIP] }
[13:09:46] NL3limin4t0r: Or make a private helper
[13:10:02] NL3limin4t0r: prepend_before_action :set_localip, only: :update
[13:14:26] NL3limin4t0r: I personally put my callbacks at the top of the controller, but it doesn't really matter. It's just preference, as long as they are in the class context of the controller you're good to go.
[13:15:41] NL3limin4t0r: ^ Assuming you want to execute it only on the `update` action.
[13:17:29] NL3limin4t0r: You still need to define the #set_localip method.
[13:18:23] NL3limin4t0r: Things don't magicly fix themselfs. In the private section of your controller `def set_localip; @localip = params[:localIP]; end`
[13:18:53] NL3limin4t0r: (replace the `;` with newline characters)
[13:39:37] NL3limin4t0r: EnderMB: Scopes are intended to return an ActiveRecord::Relation objects. From your current code it seems like you want to use it as Enumerable#select.
[13:43:05] NL3limin4t0r: Outside of the above, the main question is: Is the content that should replace `???` instance dependend or not? If it is instance dependent you can't create a scope for it using the service object.
[13:45:03] NL3limin4t0r: Not completely. The issue is that you have to rewrite the rules in Arel or SQL format. So that it can be applied as a scope.
[13:46:26] NL3limin4t0r: The other option is to simply use #select with a block. In that case the method is forwarded to enumerable and the result will be an array rather than a ActiveRecord::Relation.
[13:51:22] NL3limin4t0r: For example: Let's say I have a model Location that is only visible the location is not disabled and marked as public. In the service object you would do something like this ` && location.public?`. If you want to write a scope for it you must re-write it into "scope logic": `scope :visible, -> { where(disabled_at: nil, public: true) }`
[13:52:19] NL3limin4t0r: if* the location is ...
[13:55:06] NL3limin4t0r: Or even cleaner: `scope :active, -> { where(disabled_at: nil) }; scope :public, -> { where(public: true) }; scope :visible, -> { active.public }`
[13:56:47] NL3limin4t0r: ZAJDAN: Try the other approach. Call `set_paper_trail_controller_info` after you've set the `@localip` instance variable in your #update action.
[13:58:03] NL3limin4t0r: ZAJDAN: That method should call `info_for_paper_trail` and set the result on papertrail.
[14:37:34] NL3limin4t0r: EnderMB: That depends on the context. You can indeed do ` { |location| }` inside the controller.
[14:39:16] NL3limin4t0r: EnderMB: However, if the service object is an essential part of the model you might want to do something like `def service_object;; end` inside the Location model. Then delegate some methods `delegate :visible?, ..., to: :service_object`.
[14:39:54] NL3limin4t0r: EnderMB: You can then do `` inside the controller.
[14:42:18] NL3limin4t0r: ZAJDAN: I indeed mean like that. Does it work properly?
[14:42:40] NL3limin4t0r: ZAJDAN: You could raise an exception if the value is not present or redirect the user back.
[14:45:44] NL3limin4t0r: ZAJDAN: I don't fully get what you're trying to say.
[14:47:43] NL3limin4t0r: If the value is send in the request it should be received by the controller.
[14:53:54] NL3limin4t0r: ZAJDAN: The value is nested inside :commission. Use `params[:commission][:localIP]`, `params.dig(:commission, :localIP)` or `params.require(:commission)[:localIP]`.
[14:54:46] NL3limin4t0r: There are some diferences between the above options. What you should pick depends on the context and your preference.
[14:57:45] NL3limin4t0r: You could also use `params.require(:commission).require(:localIP)` if you want to make sure the parameter is there.
[14:58:16] NL3limin4t0r: #require raises an ActionController::ParameterMissing exception if the parameter is missing from the request.
[17:22:22] NL3limin4t0r: Quit: WeeChat 1.9.1
[17:33:23] NL3limin4t0r: has joined #ruby
[17:33:30] NL3limin4t0r: has joined #RubyOnRails


[20:28:09] NL3limin4t0r: powerbit: For me it depends on the contex. Depending on the context you could also implement the Null Object pattern and simply use `thing.method`.


[07:47:55] NL3limin4t0r: *.net *.split
[07:52:45] NL3limin4t0r: has joined #RubyOnRails
[07:52:50] NL3limin4t0r: has joined #ruby
[12:28:38] NL3limin4t0r: rbanffy: What do you mean by "why some native extensions were not build"? Do you mean the Ruby std-lib? Or what are "native extensions"?
[18:51:25] NL3limin4t0r: DoctorMonocular: I'm not exactly sure what form functionality you're looking for. But have you looked at the "Form Builders" catogory at
[18:51:28] NL3limin4t0r:


[09:42:12] NL3limin4t0r: xco: One I know of is #slice, made it from RoR to the Ruby core.
[09:44:14] NL3limin4t0r: Now I think about it, if I'm not mistaken #transform_keys and #transform_value for Hash are originally from RoR too.
[09:44:29] NL3limin4t0r: #transform_values*
[10:09:24] NL3limin4t0r: jarr0dsz: Why are you adding brackets around all parameters? Normally routes are specified like so: `get 'some/static/path/:dynamic/:id(.:format)'` The brackets denote that `.:format` is optional.
[10:12:38] NL3limin4t0r: What is the condition? Normally you would use the `:constraints` option, to add a condition upon the incoming route.
[10:12:46] NL3limin4t0r:
[10:15:05] NL3limin4t0r: The reason it's set as `params[:division_id]` is because `get '/organisations(/:division_id)'` is the first route that hits if you only pass 1 id.
[10:15:48] NL3limin4t0r: Routes are specified from top to bottom, the first route that matches the incomming request path is used.
[10:17:56] NL3limin4t0r: Ask yourself this. If I where to send a request to `/organisations/1` how would you know if my intention is to use 1 as :devision_id or as :id?
[10:19:04] NL3limin4t0r: I would not hardcode the path, but use dynamic parameters. Simply send a request to `/organisiations?division_id=1`
[10:19:29] NL3limin4t0r: This way a simple `/organisations` route is all you need.
[10:21:02] NL3limin4t0r: This can be done in the controller/view by using for example the `organisations_path(division_id: 1)` helper.
[10:22:52] NL3limin4t0r: Assuming you've the route `resources :organisations, only: :index` or `get '/organisations', to: 'organisations#index'`.
[11:42:36] NL3limin4t0r: jarr0dsz: You can assign any route to any action. `get '/organisation/profile', to: 'profiles#edit', as: 'edit_profile'` should do the job.
[11:43:07] NL3limin4t0r: Keep in mind that nested resources should be kept to a minimum. Shallow nesting is prefered.
[11:43:27] NL3limin4t0r:
[11:45:03] NL3limin4t0r: I haven't informed myself about Rails 6 yet. So I can't comment on that.
[12:31:40] NL3limin4t0r: ZAJDAN: `@commission = Commission.where(commission_num: params[:commission][:commission_num])` might be what you're looking for.
[12:34:44] NL3limin4t0r: ZAJDAN:


[09:07:38] NL3limin4t0r: ZAJDAN: You can rename/regenerate by simply removing it and generating it again with a new name `bundle exec rails destroy controller old_name ...` then `bundle exec rails generate controller new_name ...`
[09:08:38] NL3limin4t0r: ZAJDAN: But you might want to rename the controller and routes manually if you've put some work into it.
[11:33:31] NL3limin4t0r: ryouba: np, happens to the best of us
[11:54:37] NL3limin4t0r: ryouba: What if your match normally would span accros multiple lines? You currently have `"\n")` and then do stuff with just one sigle line.
[11:55:22] NL3limin4t0r: ryouba: eg. the fourth match in the rubular link.
[12:25:49] NL3limin4t0r: ryouba: I'll read it later. For now I'd like to say that the provided text looks like perfectly valid markdown, with some nested links.
[12:31:37] NL3limin4t0r: ryouba: If you'd like to remove the nesting (and preserve the outer one) the following regex will do just fine: /\[\[([^\]]*)\]\([^)]*\)\]/
[12:36:46] NL3limin4t0r: ryouba: I don't capture the match the last `(text)` since that part you place back anyways, that's why its so much shorter. `text.gsub(/\[\[([^\]]*)\]\([^)]*\)\]/, '[\1]')`
[12:41:00] NL3limin4t0r: This looks for two `[` characters, followed by any amount of none `]` characters captured in group 1. Then matches `](`, followed by any amount of non `)` characters, followed by `)]`.
[13:03:16] NL3limin4t0r: ryouba: Git(hub) doesn't always have the best change detection. When commiting haml files it sometimes marks the whole document as changed, despite adding only one line and indenting some other parts.
[13:25:10] NL3limin4t0r: jarr0dsz: Normally post is used if the instance matches the following `record.new_record?`. Check if this is the case for `@organisation.organisation_profile.new_record?`.
[13:25:43] NL3limin4t0r: add a line `- byebug` above the form
[13:26:43] NL3limin4t0r: Assuming you use haml, if you use erb add `<% byebug %>`
[13:29:37] NL3limin4t0r: Seems like it. I would use something like `@organisation.organisation_profile.new_record? ? :post : :put` so the form can still be used for new and edit.
[14:20:38] NL3limin4t0r: haxx0r: Add the word `reverse` between `rotate` and `1s` in `.inner[data-spinto="idle"]:before`.
[14:25:53] NL3limin4t0r: haxx0r: From the mdn docs it seem that you should add it between `infinite` and `liniar`, but my first comment on the matter works too in my browser.
[14:26:04] NL3limin4t0r:


[12:30:51] NL3limin4t0r: ryouba: Ruby regex have the Perl "m" option always enabled, in Ruby `^` and `$` alway match the start and end of an line. If you want to match the start and end of the entire string you'll have to use `\A` and `\z`. Ruby doesn't have the "g" option, depending on the usage it will automatically stop on the first match, or go through all matches.
[12:31:50] NL3limin4t0r: eg. text[regex] only matches ones, while text.scan(regex) matches all the posibilities.
[12:34:04] NL3limin4t0r: Ruby only supports the "m", "i" and "x" flags. From whom "i" and "x" are the same as in Perl while the "m" option in Ruby is equal to the "s" option in Perl.
[13:01:36] NL3limin4t0r: ZAJDAN: It shouldn't return "record already exist" a error message, the default value is "has already been taken". You can read the current value simply out of the attribute that has this error.
[13:05:34] NL3limin4t0r: Take for example a model `User` that has an `email` attribute, which has the validation `validates :email, uniqueness: true`. Let's say I try to create a new user, but the email has already been taken: `user = ''); #=> false` I can simply get the value from the instance, ` #=> ""` which is the value already in use.
[13:39:13] NL3limin4t0r: You could also edit the default message by updating locale/en.yml and setting {en: {errors: {messages: {taken: "your custom error message with %{value}"}}}}
[14:07:14] NL3limin4t0r: the above should be config/locales/en.yml
[18:24:32] NL3limin4t0r: comet23: It may become more clear when you rewrite the function as a while loop.
[18:31:54] NL3limin4t0r: Keep in mind that both variants drop into an endless loop if you provide a negative exponent.


[17:14:05] NL3limin4t0r: jstrong: Adding a reference to what jhass already said.
[17:19:06] NL3limin4t0r: xco: The command `rails new rails-react-tutorial --webpack=react` is merly to simplify the setup of an project Running rails and Node, this should add the `react-rails` gem to your gemfile. Having the gem installed is still needed.


[15:18:07] NL3limin4t0r: jstrong: I'd change `belongs_to :account` to `belongs_to :account, optional: false`. Make sure the SQL column is NOT NULL and remove the presence validation.
[15:20:39] NL3limin4t0r: You should also have a foreign key from account_id to
[15:21:28] NL3limin4t0r: =>*