Jacob Montgomery

Joined

34,480 Experience
33 Lessons Completed
41 Questions Solved

Activity

Aye, if you check the docs (under the options section) you'll see it will pass any additional options as regular tags which is really snazzy.

https://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-button_tag

The biggest down side is IE compatability (who'd a thunk?) - so you'll still want a fallback solution if you need to support IE 11 or older. https://caniuse.com/#search=form

Excellent!

Cheers!! :)

Great!

You may consider setting a fixed ID to the form so its always the same. You may have issues if your form is now edit_product_4 but your button was hard coded to edit_product_3 unless you're dynamically setting the form: option as well to account for that.

Hey Alan,

Are you using this button outside the <form> tags?

Check out https://stackoverflow.com/a/12567605

You'll need your form to have an ID and use that in your button form: 'form_id'

Looks like there may be some issues in IE with it though, so you may consider a JS solution if you need to support IE older than Edge.

Posted in migrating to php

Hey vampster,

Does it use the original hash, concatenate the new argument to it and hash the resulting string?

In this particular case, yes. So for example if you have var = 'foo' and then var << 'bar' the value of var will now be 'foobar'

> digest = Digest::MD5.new
=> #<Digest::MD5: d41d8cd98f00b204e9800998ecf8427e>
> digest << "foo"
=> #<Digest::MD5: acbd18db4cc2f85cedef654fccc4a4d8>
> digest << "bar"
=> #<Digest::MD5: 3858f62230ac3c915f300c664312c63f>
> digest.hexdigest
=> "3858f62230ac3c915f300c664312c63f"
> var = 'foo'
=> "foo"
> var << 'bar'
=> "foobar"
> var
=> "foobar"

Check out https://medium.com/@AdamLombard/easy-ruby-plus-equals-vs-shovel-6f030875e366 if you want more details on the << function

Posted in Stuck on creating new record

Can you verify your new method? Above its Accounts.new (plural) but it should be Account.new (singular)

You also have class AccountController < ApplicationController which should use the plural form class AccountsController < ApplicationController

Check https://alexander-clark.com/blog/rails-conventions-singular-or-plural for an outline of the rails naming conventions.

Are you using the rails scaffold generator to generate your models, controllers, and views? You'll want to read up on them if you haven't, it will show you the "rails" way of doing things while working on your project.

Posted in Stuck on creating new record

Hey Nelson,

You should be able to just remove account_path from form_for. Rails is smart enough to parse the correct paths from the object as long as you stick to the rails convention.

https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_for

Posted in How to get param values through radio_buttons ?

Hey rodolfo,

You need to add the value you want passed for each radio button. If you check out the docs, you'll see the structure is: radio_button(method, tag_value, options = {})

So your tag should look like this:

<%= f.radio_button :responsible_id , client.id, id:"responsible-manage-#{user.id}", class:'custom-control-input' %>

Googling the error message "Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0" returns the following guide:

See if that gets you any further. Are you using a VM or something? I'm not really sure why a vanilla install of Ubuntu would be giving you all these issues.

What's the error when you run gem install pg -v '0.18.3'

Ok I see, you could put a status field on the member object so you can filter out members who haven't accepted their invitation and then change the status once the user has accepted the invite. This would allow you to periodically delete invitations that are over X days old so you don't end up with a bunch of abandoned records.

Another option would be to store the team ID on the invited user object so once the user accepts their invitation, you then create the member object since that really only functions as a join table between the user object and the team object.

There should be more to the error message, can you supply that? Did you install postgres? https://gorails.com/setup/ubuntu/16.04#postgresql

Hey rodolfo,

What problem are you trying to solve by creating the member only after the confirmation?

Asssuming you're talking about the app you're taking over... once you have rails and ruby installed, you'll need to copy the application over to your development machine (where you just installed ruby/rails) and then cd into the directory you just copied and run bundle install - once that is complete you'll need to setup the database - rake db:create then load the schema - rake db:schema:load. If there is any seed data (check the db/seeds.rb) you can load that with rake db:seed - now, if the app isn't in too much disarray you should be able to start the rails server with rails s

What version of rails is the app you're taking over?

When following those instructions, be sure to change the version of Ruby and Rails to the version of your app... so for instance, if your app is using ruby 2.3.1 and rails 4.2, instead of copy/paste whats in the instructions, you'd change the versions like:

rbenv install 2.3.1

and

gem install rails -v 4.2

Hey Neville,

How are you installing ruby? Are you using a version manager such as rbenv or rvm?

Did you install bundler? gem install bundler

Take a look at the guides Chris has for installing rails on ubuntu: https://gorails.com/setup/ubuntu/16.04 *updated for your version

Hey Neville,

Since you're taking on the project fresh, I would suggest installing ruby 2.3.1 on your dev machine instead of trying to upgrade the app to the latest version. This way you can get the app working locally before trying to make any changes to the app.

After you've got the app installed and working and you're ready to upgrade the ruby version, you can open the applications Gemfile and look for a line that says ruby "2.3.1" and change it to ruby "2.5.3".

Posted in Chart Size Convert

You can keep using Chartkick for your simpler charts, then for your more complex implementations you can bypass Chartkick and embed the chart.js manually.

Creating a chart:

Example usage in an ERB file:

What you're looking for to format the tooltip is the tooltip callback function

In the example erb file, you'll see you can put the js code directly in an erb file and then pass the data in as you would any other view. You'll notice I put raw before the data variable, I'm not 100% sure this is necessary but I think it will be, otherwise, your array will be wrapped in quotes.

I would suggest trying to get the chart embedded with some data, once you have that then you can start working on manipulating the tooltips to display as you need. One other thing you'll need to be aware of, you'll most likely have to do the byte to mb/gb/tb in js instead of ruby. You can check out this SO for an idea on how to handle it - https://stackoverflow.com/a/18650828

Posted in Chart Size Convert

I think the solution is going to be a bit more complex.

I realized that you're probably going to run into a situation where a data point of 100gb will appear higher on your chart than a 1tb data point. As far as I'm aware, chartkick isn't parsing the unit of measure so all it is seeing are the values 100 and 1 in this example.

In some libraries, you can pass in the data point value along with its label value or at least format the label value separately from the point value. This way you could pass the data point value as the raw bytes so you avoid 100gb being higher on the chart than 1tb and then manipulate the label value so you can display the properly formatted value (1tb, 100gb, etc).

I glanced at the chartkick docs and I'm not seeing that ability, but that doesn't mean I didn't overlook it or dig deep enough to find that feature. What charting library are you using within chartkick?

Unfortunately this is about as far as I can help on this specific issue until I can get more time to dig into it more, but I doubt that will happen in the next few days. Hopefully someone with more experience with chartkick and the specific library you're using will chime in.

Posted in Chart Size Convert

Ahh ok, I see what you're doing.

The best I can come up with is to take the return of your code and apply the number_to_human_size with an additional map like so:

<%= line_chart Item.group_by_month(:created_at).sum(:download).map{|k,v| [k, number_to_human_size(v)]} %>

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.