Leave a comment

Rails – complex rake task


I had to write a pretty complex rake task this evening.  I made some seriously big changes to my client app and need to run some processes to update some big changes in the database.

The first question I had was where to add a method that the rake task could call.  While this seemed a pretty easy thing to do, a google search led me no where so I went with trial and error.  In the end I found that the method needed to go AFTER the task do block and not in it.

desc 'this is the description of the task'
task do_something: :environment do
 my_objects.all.each do |object|
   object.do_something_cool
 end
end
def do_something_cool
 something_cool
end

The next thing I want to do was to use an existing helper that was in my Rails project.  This was easily found with Google.

You simply need to require the helper file and include it.  I added this between the dec and the task do block:

require "#{Rails.root}/app/helpers/my_helper"
include MyHelper

Hope this helps :)

Leave a comment

Ruby on Rails for Beginners


Bob Roberts:

Super deep RoR for Beginners

Originally posted on Ashish Patil's Blog:

If you’re like me, you’re reading this on your bright-red custom-built laptop in a soothing rosemary-scented bubble bath, and you’re wondering, “Why do I want another interpreted programming language? I can find my way around Perl and PHP and maybe a little Python. And Unix shell scripting. I feel fine. Why do people keep talking about Ruby?”

Contents

  1. Why Ruby is Cool
  2. Why Rails Is Cool
  3. Installing Ruby and Rails
  4. Using It
    1. Step one:Set up the database
    2. Step two:Create the scaffolding
    3. Steps three and beyond:Customize the application

Why Ruby is Cool

Like so many of the very coolest things, Ruby was invented in Japan in the ’90s. Ruby is purely object-oriented; even things like integers and strings have intrinsic methods and properties. So, for example, print "Webmonkey".reverse outputs “yeknombeW”. It’s a clean, pretty language, with a flexible, predictable syntax that’s easy to read and write, and comfortable for people…

View original 1,871 more words

Leave a comment

Why Use Ruby On Rails?


Bob Roberts:

Nice short read on benefits of Rails

Originally posted on Socialzinger:

When it comes to having software developed, there’s no lack of options when it comes to the technologies you can use. But depending on what you need your application to do, certain technologies are going to be a better match. For most of the custom applications to build, a lot of developers use Ruby on Rails. Here’s a quick background on Rails, why its a good match for most web applications, and why you might want to consider it if you have a web application project in mind.

Ruby on Rails Ruby On Rails

In cases, business owners needed something much more customized, with specific features based on their business needs. When this comes up in business, my go-to tool for building these types of web applications is Ruby on Rails.

Note: I want to be clear that I’m not necessarily saying that Rails is the best option for all types of projects. But…

View original 740 more words

Leave a comment

The venture capital firms that are best at spotting unicorns


Originally posted on Quartz:

This post has been updated.

Last month, Quartz went hunting for the biggest “unicorn makers” in the venture capital world. By analyzing data from research firm Pitchbook, the goal was to find out which firms participated in rounds that directly pushed a startup’s valuation to $1 billion or more.

Accel Partners and Insight Venture Partners came out on top, each with seven deals that helped propel a startup to “unicorn” status. But since the scope was late-stage deals, some readers noted, rightly so, that these firms were simply riding the wave, investing in fast-growing-yet-established startups, such as Slack. For investors with deep enough pockets, it’s easy to go “logo shopping” and invest in hot startups, solely to be associated with them. (The data, however, did include follow-on deals, or subsequent investments in startups the firms already had a stake in.)

But getting in early is often where the biggest returns are. Making those types of investments also requires guts and foresight since they’re bets…

View original 255 more words

Leave a comment

Offshore, nearshore, come ashore – Bringing Rails Team in house


I just made my first year where I work and it has been crazy fun and challenging.

When I started a year ago, our application was in the hands of near shore developers.  They had just taken over from off shore developers a couple months prior to my coming on board.  They were by far still in the learning curve.  The first deployment we did after I got there was a team effort and a load of finger crossing.

The near shore team did an excellent job learning the application and where churning out user stories like mad.  As they were all located in Mexico there was no time difference to speak of and with the help of Skype and daily standups, we were able to work efficiently.

Shortly after I started working here, I started to build my in house team.  Finding good available Rails developers in the Phoenix area is quite impossible.

My first hire was somebody that was previously one of my interns for my company.  I had to pay pretty good to convince him to come on board.  He was quite happy with his current employer.

From there the search was difficult.  We ended up bringing on a couple of interns from ASU and I just had the pleasure recently to hire one of them on full time.  Another developer that was in the learning phase keep hounding me and we brought him on as a junior Rails developer where he has continued to excel.  Another developer expressed interest in working with us.  We brought him on as an intern and was recently made a full time employee as well.

Other additions to the team were a top notch Project Manager and a Senior SysAdmin to handle the multiple servers.

Last month the contract for the near shore developers was up.

We are all in house now and working on site.  The old saying cant teach a dog new tricks really means something sometimes with senior developers.  They sometimes get stuck in their ways.  New junior developers looking to make a living programming are generally eager to learn and so far I have had success with 5 out of 7 interns.

They cant get hired without experience and can’t get experience if they don’t get hired.

Try hiring a developer intern.  Check out the local universities that have CS programs.  If you can’t find great developers; build them.

Leave a comment

Managing Developers – How not to suck


Originally posted on Foredecker:

I’ve been a development manager for 15 years. I have had the privilege to manage some great people – many of whom have become lifelong friends. I’ve also managed people I never want to hear from again. I’ve had some good mentors along the way and I’ve worked for some great mangers, a couple of crummy mangers, and one psychopath. It’s been both a rewarding and challenging experience. People who have worked for me tell me I’m a pretty good development manger.

Along the way, I’ve gotten to know many other development mangers. I’ve seen a few really good ones, and many bad ones. I have enjoyed working for a world class manger at Microsoft. I’ve also seen a couple of mangers who have been fired for how badly they manage people.

Managing developers is really hard. Why? Because software development is fundamentally a creative activity, like music, art, architecture…

View original 252 more words

Leave a comment

How to Set Up Flash Hashes and Error Messages in Rails


Bob Roberts:

So simple but so many do not use this. We have a legacy app that has NO error messages. Try to login with wrong email, it just does not work but no message to tell you why. Seems like this should be a standard thing.

Originally posted on christopher r dodd code:

Notices

1. Setting a notice

Setting a flash notice is as easy as assigning it to the flash object

flash[:notice] = "The subject was created successfully"

Where should you put it?

A good place to put it is in the controller after the object successfully saves or is destroyed. For example:

def create
  @subject = Subject.new(subject_params)

  if @subject.save
    flash[:notice] = "Subject '#{@subject.name}' created Successfully"
    redirect_to root_path

  else
    render('new')
  end
end

2. Displaying the notice

If using Bootstrap and HAML, you can put this in the view where the user gets redirected to

-if !flash[:notice].blank?
  .row
    .notice.alert.alert-success
      =flash[:notice]

If you’re not using Bootstrap or HAML, try this:

<% if !flash[:notice].blank? %>
   <div class="notice"><%= flash[:notice] %></div>
<% end %>

Errors

1. Write your validations

For there to be errors, you need validations. If you haven’t built validations, I suggest you do this now.

2. Generate a partial for displaying your…

View original 62 more words