shakycode

Joined

5,390 Experience
2 Lessons Completed
3 Questions Solved

Activity

Posted in Javascript frameworks videos?

+1 for React - Flux. I'm learning about this now and how to couple it with Rails. Maybe a simple blog application can be created and then demonstrate React's voodoo from there. If you want me to build a simple app and roll everything together, let me know. I'd love to help. I can also come up with some good ideas on demonstrating React.

Not a problem, glad I could help! Let me know if you need anymore help.

Posted in Multiple Rubies using Rbenv

Right you are sir. Actually there's been talk of shipping bundler with Ruby, although I forget where I saw it. That would be nice though. Having the .ruby-version in your repo also helps when you are switching Ruby in both dev and prod. Although I don't think I'll tackle upgrading Ruby in production this week. :)

Posted in Updating Rails Applications across Rails versions?

Sorry to bump an old post. But I wanted to chime in on my experience with the upgrade process.

I recently upgraded a Rails app from 3.2.21 -> 4.0 The biggest issues I ran into were my models and controllers since the 4.x.x series introduced strong_params. So there was a lot of manual work to get things working properly with Rails conventions and getting away from attr_accessible. Once I got past that mess, like Chris said the gems are a pain in the ass. Especially if you are changing Ruby versions as well as updating Rails. I'm pretty much done with the upgrade but it's taken me over a month to solve all the gem problems that crept up. But really it's just taking one step at a time and getting it nailed down.

Hope your upgrade goes smoothly!

In your admin controller you need to instantiate @article in your Admin Controller's index action. Something like this: @article = Article.order('created_at DESC') or simply @article = Article.all if you don't care about the order it should default to sorting by .id

Posted in Any good regex rules for validation?

Thanks to both for the information. I've been looking for some regex tips on validating URLs and some better email validation techniques. :)

Posted in Multiple Rubies using Rbenv

Sweet, thanks for the answer Chris. I was overcomplicating it I think. I went into a newer repo that needs Ruby 2.2.0 and just did

cd newrepo
rbenv install 2.2.0
rbenv local 2.2.0

And it did the same thing as echoing the version in your example. But your way seems way simpler. :) I'm going to do this for all 5 of my existing apps and set their versions (which is unfortunately all 1.9.3-p194). Then I'll do the same for the new apps I build.

I noticed when I cloned a new Rails 4.2 app repo and tried to do bundle install to install dependencies it said bundle command not found, exists only in these versions 1.9.3. So I ran gem install bunlder to get it to compile against 2.2.0

I think I'm in a better place now. Thanks for your help as always. I'm sure I'll be posting more often.

Posted in Multiple Rubies using Rbenv

I'm having total brainfog right now with rbenv, so please excuse the newbie question.

I have rbenv installed and my global ruby install is 1.9.3-p194 which I've developed multiple apps in. I'm working on new apps and would like to use 2.2.0 alongside Rails 4.2.0. I want to keep my legacy apps working in development using 1.9.3 but also work on the newer apps using different Ruby versions.

Wouldn't it be something like this?
rbenv install 2.2.0
cd ~/code/mynewapp
rbenv local 2.2.0

This should generate a .ruby-version file which tells rbenv what version to use right? Then from there I can bundle my new app and build the gems/etc?

Would it make more sense to install Ruby 2.2.0 then set it rbenv global 2.2.0 then in each Rails project I'm working on do rbenv local 1.9.3-p194 for each project that I'm using so it doesn't break things?

I'm just concerned about wiping out my dev environment and having to start from scratch which would waste time.

Posted in Best way to render a page as a PDF

I totally forgot about Wicked. It's also a great gem, but there are some gotchas with it as it pertains to stylesheets and layouts. Once you get the hang of it, it's pretty straight forward.

I agree, Prawn is annoying to use but it just works. I have noticed that it's a bit of a memory hog when rendering PDFs with heavy loaded objects.

Posted in Is Devise always a good choice?

I jumped on this thread late, but I would highly recommend Devise. As Chris said, it's well tested, very mature, and feature rich. As well if you really want to lock things down you can use the Devise Security Extensions. It also plays nice with CanCanCan and/or Pundit.

Posted in Best way to render a page as a PDF

I use Prawn exclusively to generate PDFs. The template system and DSL takes a bit to get used to but it's a viable solution. Also PDFKit is good but I've had more luck with Prawn.

What obstacles are you facing that you need help with?

Posted in Displaying an address from a selected location

Awesome Chris. I'll give this a try today. I'm using Rails 3.2.21 and regular forms, not Simple_form so I can convert it. Syntax looks way different than my collection select, but I'll give it a shot. Definitely put me on the right track. You're the man :)

Edit: Actually I'm using grouped_collection_select in my form. Should this matter?

Posted in Displaying an address from a selected location

So in a form I have locations which are set in a collection_select statement in the form. Each location has a name (Dairy Queen, McDondalds, etc) and has an address in the Location model. When selecting a location from the drop down, I'd like a small div to show up next to the location name that displays the address. I think I can do this with CoffeeScript but not sure on how to do this cleanly. I'm trying to keep this specific to jQuery or CoffeeScript instead of having to use mustache or another rendering template.

Any advice on this? This is less of a Rails question but figured you might be able to shed some light on this.

I had a similar problem in the past with www-data and permissions on static assets out of the app's public folder. I did what Chris did and changed my Nginx user to deploy to alleviate the issue. It also allows the deploy user to HUP Nginx if need be without having to do sudo.

Posted in Dynamic view based on associations

I need to start using friendly urls in my apps, so tired of ugly urls with ids in them. Time to do a bit of refactoring across apps and install friendly_ids.

One thing I had a question on in the query for the controller code is where am I getting the id for region from? I'm wanting to iterate over several regions (Houston, Dallas, Austin, etc) so I'm not sure how to pass that through to the controller from the view. The only thing I can think of is a dropdown that allows you to select region, shoots the region.id to the controller to query for runs matching that id. Maybe I'm making this way too confusing than it needs to be.

Posted in Dynamic view based on associations

Sorry, I probably should have clarified things better.

I think creating a route for /runs/region/:id would work just fine and the query looks pretty solid. I'm a bit confused on the permalink that I'd be passing into the scope. Can you elaborate on that? I'm not using friendly or anything like that.

Posted in Dynamic view based on associations

I'm trying to add some view logic functionality to one of my apps. I have a "run" view that lists all runs and splits them up in a partial between active and pending. Each run also belongs_to :region. So what I'd like to do is have some sort of tabbed view of all runs but allow switching between regions. I can setup something like this by using a named scope where the run's region equals the string name or id of the region. But considering there could be numerous regions and they may change as time goes on I'd like to avoid iterating/scoping over regions as strings.

What would be the cleanest way in the controller and/or model to allow switching between regions in the run view?

Posted in Suggestions for messaging

I've done some research on Pusher but I'm doing my best to keep the 3rd-party API dependencies to a minimum. Although pusher does an excellent job with realtime messaging and events. Then there's also the cost associated with it, which I'm trying to eliminate. It's bad enough that I'm pouring through $100/mo easily with Twilio on both apps.

Maybe you can do an updated screencast on Faye? I've played with it a bit but always got stuck when trying to associate channels and devise users. I'm not totally opposed to the technical debt of having to run more in my stacks, but less is more as always. That's one of the reasons why I was looking at the mailboxer gem to make a model messageable. Seems like a simple drop-in process compared to having to architect a lot of moving parts.

Posted in Suggestions for messaging

I'm working on a couple different apps right now. One is new and one I'm refactoring some new functionality into. I'm looking to add messaging between users in both apps.

I'm up in the air on the best way to do this. I was initially thinking about a faye pub/sub setup to allow users to chat, but there's significant technical debt associated with this. My other thought is to use the mailboxer gem to handle messaging then some sort of polling via ajax to notify users of new messages in the nav.

Any thoughts on what's the best route? My goal is 2-way conversations between users, whether it's in realtime or close to realtime.

Posted in Search functionality for the screencasts

Same reason I'm trying to write my own version of Devise and CanCanCan, practice :)

Ransack would probably take care of everything I need, but I'm fascinated as of late with writing things from scratch.

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.