Chris Oliver

Joined

292,890 Experience
93 Lessons Completed
295 Questions Solved

Activity

Ah yes! I'll have to do an episode on that too.

Posted in Upload Progress with Refile Javascript Discussion

If you pass the same parameters to the URL as the HTML form that gets generated it will work. Of course, you will need to make sure the mobile user has a way to authenticate as a user for that request by setting a cookie or using an API token. Mobile apps talking to a Rails app are basically the same as your browser, you just have to worry about things like cookies/API tokens.

I don't think you can with ActiveRecord since you need a database migration to add it. That's a great point for MongoDB users though! Super simple.

Posted in File Uploads with Refile Discussion

I did forget to include that. It's an awesome little feature along with deleting uploads. It definitely still is pretty new and you can do everything with Carrierwave no problem.

That could definitely give errors when nginx tries to serve them up. One thing you can do is change the nginx user to deploy. I often do that so I don't have to worry about accidentally messing up www-data ownership when I deploy.

Yeah whoops. Redcarpet doesn't do well with it apparently. Updated.

Interesting. Those should not be hitting Rails.

Maybe try this instead of the location block:

server {
  listen 80 default_server;
  listen [::]:80 default_server ipv6only=on;

  server_name xxx;
  passenger_enabled on;
  rails_env    production;
  root         /home/deploy/xxx/current/public;

  error_page 500 502 503 504 /500.html;
}

Those should automatically get served up. Can you post your config? Anything in your logs that doesn't look right?

Posted in Radio buttons as actual buttons

The Bootstrap code should actually check the radio buttons for you. You don't need to use a hidden field because with radio buttons, you set the same name for the different inputs and the browser submits only the value of the checked one. Does that make sense?

Posted in Build REST API with Devise

I think you can just simply make a POST to the same url as the sign up form normally which is /users. Same with PUT and DELETE but for logging in and out, you want to POST and DELETE to /sessions because that's a separate controller.

Posted in Upload Progress with Refile Javascript Discussion

As long as you can calculate the percentage, all you need is some CSS. Bootstrap ships with a progress bar and all you need to do is set the width to the percentage complete. http://getbootstrap.com/com...

You can find many others if you're not using Bootstrap and you just google "css progress bar"

Oh nice. I rarely tend to customize Devise routes so it has been a while since the last time I did it. Glad the gist you found worked!

Posted in Radio buttons as actual buttons

I think you'll need to use Javascript to pull it off. If you use Bootstrap it comes with support for that kind of functionality. http://getbootstrap.com/javascript/#buttons-checkbox-radio

You might also be able to do it with pure CSS but it looks like you need to use JS for IE8 support: http://stackoverflow.com/questions/5523735/how-to-make-a-radio-button-look-like-a-toggle-button

Posted in Updating Rails Applications across Rails versions?

Haha! I don't think we would have done the acquisition if it wasn't to make things better.

Rails is definitely a tough nut to crack. It took me a long time to learn it and I was already familiar with building things in Python.

With some simple gems, you'll probably just need to upgrade the core Rails code and the rest of it should be pretty good to update just buy updating gems.

Posted in Markdown/Emoji : how to host images?

I can't remember where I grabbed that from exactly, but some documentation somewhere. If you want to host your own, check out https://github.com/HenrikJoreteg/emoji-images and you can serve up the pngs folder in your app. Of course, you'll want to put those in your public directory and not the asset pipeline so they stay the same filenames and don't get compiled.

Posted in Soft Delete with Paranoia Discussion

Correct for most cases, but when you don't want to expose any deleted records, default_scope is perfect for this.

Posted in Updating Rails Applications across Rails versions?

This definitely deserves a screencast. I should have recorded one when I upgraded One Month's site to 4.2.

My approach to this is to update your app and configs with the changes you get at http://railsdiff.com. Then I run bundle install, see what breaks (usually gems) and then start picking away at things. It's most likely that your code isn't the one that breaks, but gems will. Then it's often just going through each gem that stopped working, looking at their documentation and seeing if you're any major version numbers behind. Follow their upgrade process and one after another, you should get there slowly.

It took me 3 weeks or something (not fulltime) to upgrade our app from Rails 4.1 to 4.2 because of all the gem dependencies we have that needed changing.

On a side note, I think you can just use render text: "asdf" on Rails 4.x and earlier without having to use render plain: "asdf" plus you can pass in an option if you need to change the content type.

Posted in File Uploads with Refile Discussion

I think Carrierwave does and I use it for almost everything right now.

Posted in File Uploads with Refile Discussion

Not at the same exact time just yet, but that's on his todo list to add as a feature. https://github.com/elabs/re...

The main difference is usually the Free episodes are basic or common things people need to do and Pro episodes are more advanced or deeper looks into those things.