Chris Oliver

Joined

290,710 Experience
86 Lessons Completed
298 Questions Solved

Activity

Posted in Nested attributes permit

Hey Sebastian,

To properly use accepts_nested_attributes_for, your form needs to submit the mails_attributes key. Yours is called just mails, so you'll need to check into what's going on that it didn't generate the correct name there.

Your form should have a <%= f.fields_for :mails do |m| %> line in it which triggers it to generate those fields with the correct mails_attributes name.

Posted in How do I process request with parameters

Hey Mike,

You would take the param and then query the database with it in your SQL.

Something like:
Article.where("title LIKE ?", "%#{params[:query]}%")

Posted in Dubugging

Typically you'll install an error tracking tool like Airbrake, Sentry, Rollbar, etc and then inspect the logs to see what happened. You can then try and reproduce the error in your development environment.

Sometimes using something like devise_masquerade is helpful so you can login to a problem account and see what's going on first-hand.

Yeah, sounds like you don't have rbenv in your PATH env var.

And you're right, never use sudo because you'll end up with permissions errors.

Posted in Security Hardening Servers with Fail2Ban Discussion

I've got another one coming up soon on a tool called Cockpit which is pretty neat.

Posted in Ruby new

Hey Naldio,

The forums are a great place to ask questions. Just post your question along with code, any errors, stacktrace, and any other information you can include so we can do our best to help you! 🙌

Posted in Impossible to install Nokogiri - OSX Mojave 10.14.2

Getting closer it sounds like.

Try this and see if that helps.

gem install nokogiri -- --use-system-libraries --with-iconv-dir=$(brew --prefix libiconv) --with-xml2-include=$(brew --prefix libxml2)/include/libxml2

Alternatively, this one does the seame thing but doesn't use the libraries from homebrew in case the above fails:

gem install nokogiri -- --use-system-libraries=true --with-xml2-include="$(xcrun --show-sdk-path)"/usr/include/libxml2

According to Nokogiri's issues, they might have a fix coming out at some point soon so you won't have to do these workarounds. https://github.com/sparklemotion/nokogiri/pull/1851

Posted in Impossible to install Nokogiri - OSX Mojave 10.14.2

I'm still on High Sierra for my main computer, but let me open up Macbook which I upgraded.

My guess is that it's simply looking in the wrong folder still.

Did you try this line I had in the guide?

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

I noticed that the Nokogiri docs had a slightly different one.

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

Posted in Impossible to install Nokogiri - OSX Mojave 10.14.2

It says libxml2 is missing. so you might have just missed installing that dependency.

That's a simple brew install libxml2 to fix. 👍

Posted in Auto saving forms as they type.

First thing you'll need is a state column so when you click New, it creates a record in draft state so you can save all the changes to it.

Then I would just add some JS to submit the form via AJAX every once in a while. GMail does it after you stop typing for a few seconds, or you move your cursor out of the text box for example. The exact details on this probably depend a bit upon what your form looks like.

Saving the draft changes is really just submitting a PUT to the update action because the record's in draft state, you can just use the regular update. When you are ready to publish it, you can submit the new state or have a special publish action if you wanted to do more with it.

This would be a great screencast. 👍

Can you post your CommentsDatabale class for us as well?

Hey Victor,

Are you sure fetch_records isn't a method you're supposed to define in your class? From the examples for the datatables gem, it looks like you typically write that method yourself in the class.

You'll probably have to share some code because there's not information to help you right now.

Have you added this to your class?

  extend Forwardable

Posted in Login with Facebook Discussion

I try to never use OAuth to login unless it's something that'll need access to that account (like a deployment tool that needs access to Github, might as well login to the app with Github then). It makes perfect sense in this case.

The thing I don't like is using social login on a website, you can't use the app anymore if you stopped using the social site. That's crappy and with lastpass, etc it's real easy to just generate passwords and login with email anymore. And phones are getting better about this too, but they still lag behind a bit.

Mailchimp has a great post on social logins that has since been taken down it seems: https://web.archive.org/web/20180820002438/https://blog.mailchimp.com/social-login-buttons-arent-worth-it/

They're supposed to start using Chromium in the future, so we might have browser compatibility after all in the future! how weird will that be??

Hey Bigyan,

Check out this article on Heroku with the Rails asset pipeline: https://devcenter.heroku.com/articles/rails-4-asset-pipeline

The assets are designed to compile on the fly in development, but for production they get compiled and minified during deploy. Heroku also needs your Rails app to serve static assets, which is not the default for production. Normally, NGINX would do this but Heroku works a bit differently.

Oh neat, so you can have a button_to that submits a specific form?

I had always used it to have it submit a POST to a URL instead. Today I learned. 👍🧐

Posted in Upgrade to Mojave on Mac OS

Yeah, I do use Capybara. I tend to stick with the Rails official testing tools, and their system tests are run with Capybara. https://guides.rubyonrails.org/testing.html#system-testing

Posted in Upgrade to Mojave on Mac OS

It looks like there's a solution for that now at least: https://stackoverflow.com/a/53642942/277994

Let me know if that works for ya!