Offer HN: Help with Ruby on Rails

41 points by vgurgov ↗ HN
Inspired with latest topics on legal and design help.

I cant help you with some simple stuff for your RoR project. Maybe converting your mockups to HAML, working on backed, consulting on something, scalable deployments, adding couple nice features etc. Anything that can be done within 2-5 hours.

You must be not concerned with NDAs stuff.

Feel free to reply in this tread (If you are RoR developer willing to give back to community please comment as well!)

About me: I am doing this startup - Videolla.com and contracting on Rails to bootstrap it. Have over like 4 yrs full-time Rails contracting experience.

58 comments

[ 2.9 ms ] story [ 123 ms ] thread

  You must be not concerned with NDAs stuff.
Out of interest: why?
I can send you email confirming that i have no interest in your project, but I am not going to spend my time scanning and faxing some stupid stuff.
NDAs put you at a ton of risk. What happens if what they're working on something that you've had rolling around in the back of your mind? Now you can't work on it without facing legal action.

I can't find the original post, but NDA = "No deal, amateur."

I'd like to give back, too. I don't mind NDAs either, as long as I don't have to fax anything.
i'm on the ground level of my own startup -- and need some engineering advice. i'm torn between php+mysql & rails at the time. hit me at joe@celsius.ws if you could.
I'm the rails newb on a small team. (Many years other programming experience.) I don't have any small projects to hand off, but I'd love another person or two to bug on gchat or aim when I'm trying to figure out what is the Rails Way of doing something.
I'm a rails developer and would also be happy to help with a rails project.
I was thinking of posting something similar. I don't have much pedigree but I would love to help out on small stuff similar to what the OP has posted. My web site http://rohitarondekar.com -- There is a contact form there if you are interested. Cheers.
Hi,

My buddy and I built a social network for the iPhone. Has 25,000 users and growing. We are looking to build an admin portal on the web to facilitate moderating users, groups and messages as well as some other things. We like what we have learned about Rails but dont know much about it. A lot of our web services for the app are built with PHP but we have a MySQL database storing the content. I imagine that isnt an issue for Rails.

Anyway, would be interested in talking through some of the advantages and disadvantages of RoR and perhaps get you involved in some capacity.

Do youhappen to have examples of stuff you have built in the past?

If you have PHP site i'd strongly suggest to keep going with PHP admin backend.

Otherwise you need to re-engineer all model mapping in Rails. Technically possible, but hardly makes sense. My email is vlad@videolla.com

I've had two related questions about Rails [1] for a few years and never found a good answer. Perhaps you could help me?

1. I'd like several submit buttons on a form that do different things. I'd also like to input data alongside some of the buttons, e.g. to allocate some % of a resource.

My problem is I can't work out how to sensibly do this without repeating myself, or having a very hacky controller. How can I do this without matching on the value part of the submit buttons (the text on the buttons, since that is bad for i18n and in some cases the text is the same anyway), and without using any javascript?

2. If you have two forms on a page, can you set it up so changes on both forms are saved when any submit button is clicked? Again, without javascript. Obviously you need to override the form tag generator so the page only has one actual form; is there a standard solution to this somewhere?

[1] http://stackoverflow.com/questions/461790/multiple-submit-bu...

General advice first :)

If you can't get stuff working with the rails helpers you can always hand write the html yourself. I need to do this once in awhile. I prefer using formtastic for my current project and I've had to hand write some html to add custom logic to a formtastic form. (I prefer not to abstract one off hacks until I need to do it twice)

Rails does a lot of stuff but it doesn't do everything. If the built in tools don't do it, build your own.

> 1. I'd like several submit buttons on a form that do different things.

The only way to target these is javascript hackery, use the text on the submit button or find an alternative method that doesn't rely on multiple forms.

> 2. If you have two forms on a page, can you set it up so changes on both forms are saved when any submit button is clicked?

Without javascript, not happening. For a rails solution to combine two forms, look at fields_for.

All that said,

Without specific details (screenshots, etc.) I can't really figure out what you are trying to do. I assume you have a valid reason for asking the question. Sorry if I wasn't able to help.

Thanks, this was helpful, especially fields_for.

On the point of building my own, that's what I've done, but these felt like an obvious things to want (I implemented them both in my own PHP framework.) Thinking about it, the standard Rails CRUD index provides delete links instead of buttons; IMHO that is totally wrong, but when all you have is a hammer... Also, button_to is not good enough as it makes its own form, which breaks any solution to question 2.

On question 1, what I want is to generate submit buttons like <input type=submit name=some_non_clashing_string_that_identifies_this_button value=ButtonText> and then have this routed to a function nicely. I've not found a standard way of doing that; maybe I should write one? Could you see it being useful?

It definitely sounds like you are doing something wrong. Rails really wants you to do things it's way. You don't have to, rails, especially version 3, is only generated html and routes to functions. It just generates a lot of stuff for you. If you want to work outside of the provided functionality it's just going to be harder.

In fact the application I'm using at work right now uses ExtJS for views and half of the data is retrieved through manual queries. Rails is not designed to do this but it can work, if you are willing to put in the effort to work around missing functionality.

I do not recommend using rails as a hammer, it's a very bad hammer. It's a chainsaw with diamond teeth and a 50 hp gas-powered engine. If you have a lot of wood to chop through, it's amazing. If you need to pound in a few nails, it's a little awkward. :)

Yep, for something simple just use Sinatra / other microframeworks.
1. Use <input type=submit name=submit value=submitbuttonN>. The server side will then get this data submit=submitbuttonN.

2. Yes. Just make the form a single big form with two submit buttons, so they look like two forms.

Thanks, but I already ruled out both of these solutions.

1. I know you can look at the value of the submitted button on the server. What you need to use is actually <input type=submit name=some_non_clashing_string_that_identifies_this_button value=ButtonText>, so my question is how do you generate those strings nicely in Rails and have the controller act on them nicely as well.

2. Of course that's what you need to do, as I said in my question. My question was, how do I make Rails do this in a nice way? fields_for helps, but I'd like to know if there is a plugin or something better.

In your view you can just do this:

    - form_for concertgoer do |f|
      = f.submit "Submit", :name => "music[jazz]"
      = f.submit "Submit", :name => "music[classical]"
That's HAML... let me know if you want to see the ERB. If you want to abstract even further you can do:

    # In app/helpers/concertgoer_helper.rb
    def music_submit(form, genre)
      form.submit "Submit", :name => "music[#{genre}]"
    end

    # In app/views/concertgoer/get_ready.html.haml
    - form_for concertgoer do |f|
      = music_submit(f, "jazz")
      = music_submit(f, "classical")
     
Then in your controller you can just do:

    music = params[:music].keys.first
That variable will either be "jazz" or "classical" depending on which button was clicked. If you want to have different behaviors you can use a case statement:

    case params[:music].keys.first
      when "jazz" then concertgoer.put_on_turtleneck
      when "classical" then concertgoer.pour_glass_of_wine
    end
As for (2), yes you can. Let's say you have a form that lets you update the status of your cat and your dog:

    # config/routes.rb
    map.resource :pets, :member => [:show, :update]

    # app/views/pets/status.html.haml
    - form_tag update_pets_path do
      .cat_fields
        - fields_for @cat do |f|
          = f.text_field :status
        = submit_tag
      .dog_fields
        - fields_for @dog do |f|
          = f.text_field :status
        = submit_tag
  
    # app/controllers/pets_controller.rb
    def show
      @cat = Pet.find_by_species("cat")
      @dog = Pet.find_by_species("dog")
    end

    def update
      ["cat", "dog"].each do |species|
        pet = Pet.find_by_species(species)
        pet.update_attributes(params[species])
      end
    end
I have a general question. More along the lines of "what's the best practice in this situation." My first RoR app (recurseapp.com) now has close to 800 signups, and about 100 active users. It's also my only live RoR app.

Now with the advent of Rails 3, my app is stuck in a limbo of sorts. I'd like to upgrade it to Rails 3, but a few gems I'm using are really resisting the upgrade, and what's worse is that there's been no movement in their git-repos for quite a while now.

I know the best bet is probably to dig into these gems and fix them for Rails 3, but I really don't feel I'm that skilled a ruby programmer. Thoughts?

I can see 2 possible solutions:

1) Dig into your problems with these gems and either fix or replace them 2) Think again if you really need Rails 3. What are some benefits that you will get from that upgrade?

I'd suggest 2 approach. Rails 2.3 is a very solid version and is used in many apps. I don't see reason to "upgrade for upgrade". Especially if there is some friction and not enough time.

I recently made very small project on Rails 2 just because all I needed was ActiveScaffold(not available in Rails3 atm)- which is really awesome for some stuff btw.

I've played with ActiveScaffold and can't say I'm as much of a fan :p

My app is currently running on 2.3.5 – I think the reason I feel compelled to upgrade is that I just hear so much about Rails 3. Good point with the 'upgrade for upgrade' point. I'll have to think about it, and yeah, it is just friction at this point.

I've just spend half a day today trying to upgrade my rails 2.x app to Rails 3. I think I am going to give up on it, as it is breaking things everywhere. The UJS is the main problem, as I have tons of AJAX things going on, and quite a few things that are not really done the 'rails way' (I was learning as I developed this App).

I guess this app is destined to stay at Rails 2 and I will just start a new one for Rails 3, once I get a good enough idea!

what gems are being a problem? there are frequently equivalents to the gems with similar APIs that do work with rails3. The rails community tends to be fickle and switch to 'next big things' a lot, which causes a bit of churn like this over time.

anyway, if you list them we might be able to make some suggestions.

I am very new to Rails and would love to see a simple tutorial going from setting up a project to making an extremely simple multi-player game, maybe tic-tac-toe, (and ideally real-time). Most importantly I'd like to know the reasoning behind doing things the way they are done.

Would you be willing?

No, sorry. Making something good and simple would take much more than 5 hours. Besides there are enormous amount of tutorials for Rails. Check peepcode, railstutorials, railscast, rubyonrails.org. Also read our Bible: Agile development on rails by DHH. If you had any experience in programming or web prog, this should be far enough to start with.
I picked up Ruby and then RoR about 8 weeks ago. I was stuck on this issue:

http://stackoverflow.com/questions/4020393/ruby-on-rails-3-f...

  If you are an expert on 3.0/UJS (can't seem to find as much 
documentation /tutorials on this), I'd even pay a nominal amount just to email you a few questions over the next few months as I learn.
In Rails 3, the javascript drivers are very hands-off (i.e. unobtrusive). The problem you're having is that your app is returning to the browser a string of javascript, but there is nothing in the page that is then executing that javascript in the context of the page.

In your original page, along with the form, you need to bind an event to the form's "ajax:success" event.

The rails.js ujs driver binds to forms and links with "data-remote=true", which is what the ":remote => true" is doing, to make them submit their requests remotely, but that is where the Rails magic stops.

The good news is that the remote requests fires off some events you can bind to, which give you access to the data returned by the server (which fire off in the following order):

  ajax:before
  ajax:loading
  ajax:success
  ajax:complete
  ajax:failure
  ajax:after
You need to bind an event to the ajax:success event of your form. So, if your form had the id "myform", you'd want something like this on your page:

  $('#myform').bind('ajax:success', function(evt, data, status, xhr){
    xhr.responseText;
  });
xhr.responseText is what your server returns, so this simply executes it as javascript.

Of course, it's proper to also bind to the failure event with some error handling as well.

I usually don't even use the action.js.erb method of returning javascript, I just have my controller render the HTML partial, and then I have a binding like this in the page:

  $('#myform').bind('ajax:success', function(evt, data, status, xhr){
    $('#target-div').html(xhr.responseText);
  });
Hey, can you help me answer this: http://stackoverflow.com/questions/4021322/belongs-to-throug...

It's an AR question that has been bugging me.

Thanks!

OK, so I don't have any experience with Rails myself but after having a quick glance wouldn't it be current_user.choices (plural) since user :has_many choices instead of singular, no? (haven't actually checked relationships between your models and whether they make sense).
I posted an answer to your question on Stack Overflow. It looks like you're trying to make the problem much harder than it actually is. I hope that helps you out.
I have this project that I've been delaying because I don't have enough time. I know a bit of Rails, but it's been almost two years since I touched it. I need someone one to help me with architectural choices (should I use Formtastic, hobo, haml, authlogic, ...) and the first model/screen. After that, I would be good to go on my own. I would even be willing to pay for a few hours.

Most of the screens are CRUD (it's a business management thing) but I want to start this project correctly.

Thanks!

can you contact me on vlad@videolla.com with details? i might be able to help.
Moving from one helpful gem to another is not too bad. You can even pretty much rewrite an entire application in haml in a single day (we did it between two people in 6 hours) so it's not something to hold off starting a project over. With that being said, I would heartily recommend haml to anyone using rails (though if you don't know the pain of erb, you'll never fully appreciate haml). Same goes for formtastic - how many forms do you have where it's important enough to delay starting over a helpful but not necessary gem? I think, in general, don't overthink which gems you need to start your project. The answer really is no gems are needed to start your project, and if you just start using gems at the beginning of your project without understanding why they can come in handy, you are finding a problem to fit a solution.

As for authentication, I am a big fan of rolling my own auth. Once you have a nice functioning authentication system you worked out yourself, moving it from project to project is simple. The problem I have had with all the authentication plugins, is they insert too much automagic in something that should be simple to understand, and realistically, is a pretty easy concept. There are many guides on authentication, and playing with it is a great way to learn several fundamental rails security ideas that will be helpful in other areas (log filtering, attribute accessors on models).

Ok I've got a request that you can bang out in less than a couple of hours. Can you design and task me with a problem that you'd like to see a web app for that can be done in 100 hours or so and would highlight Rails 3.0 features. I'll keep the code on github (victusfate there) and push the live version of whatever it is to heroku.

Basically I'm asking for a homework assignment that would help ramp up my rails skills and maybe be of use to the community. I worked on and helped complete a rails project between Oct '09 and March '10 but I ended up preferring Sinatra/Datamapper for light web apps. Now I'm looking to get back into Rails 3.0.

Here is one idea you can use for nice rails 3 app if you have like 100 hours.

LinkedIn suck. Its something from myspace age. There are multiple problems with it but its still #1 HR tool

Would be cool if you can make LinkedIn-like network or just start with directory that would be great for searching and hiring best experts.

Extra bonuses: Import users data from LI, Fb, etc Smart limiting contacting abilities to prevent spamming. Smart ratings for ppl based on their social impact (like hn karma, stackoverflow rating, github, etc)

Mortality bonus: "Pay to pitch" feature. Instead of spending $400 to post job ads on 37signals job board, recruiter can pitch his ad to top 400 Rails developers. Developers have to reply and can donate these money to some charity of their chose.

Let me know if you are interested or need more clarification with that idea

I'm interested. I'll need to slice it down for 100hours of a prototype. Let's take it to email, hit me up at messel at gmail dot com.
I'm a designer/front end developer with no idea where to start learning Ruby/Rails. Would you be able to give any insight on that?
I find the best way to start learning something new is to identify a fun but simple project that has options for expansion, and start working on it. You want the project to be one that is simple enough to not get discouraged quickly, but that is flexible enough to continue with as you get more proficient.

The reason I say find a project like this, is because if you don't have actual problems to solve, you won't know what to read about. You can read about rails routing all you want, but until you have a reason to use rails routing in any sort of complex way (resourceful nested routes, like a user has many photos => /users/1/photos) you can't really do anything with it.

Once you have a project and have questions, this is a great way to get help, however, without a project we are all flying in the dark with you :)

Hey thanks for offering to help! I'm a C#/ASP.NET MVC developer and I want to start my own project in Ruby on Rails...so I'm not new to web development or MVC, but I'm new to RoR. I'm looking for mostly architectural advice. Basically I want to be able to give you a high-level design and see if you think I'm using the correct gems and how I should go about scaffolding the project. I have ideas, I just need confirmations from someone who knows RoR and how they would go about doing it. Thanks again!
wow, didnt expect so much interest in that. I will do my best to reply to all people who commented/emailed.

Surprised to see that so many people dont know where to start with their projects. Here is my answer - just do that. Read couple books, watch screencasts and you are good to go! Thats a great thing about coding - you can always refactor it later! :)

As with vgurgov, I have a startup built on rails, and have been using rails to pay the bills along the way. I don't have much free time, but I am more than happy to field questions on AIM or with a quick phone call as long as the question has defined boundaries (not too broad, etc).
Can you write? I've been attempting to write tests and get into BDD but the documentation (if available) is not good.

I followed mhartls book, the railscasts, and the documentation of various projects but I still cannot grasp testing.

How does rspec, cucumber, factories, shoulda etc etc etc all fit together? What do I use each for and when? What does a good test consist of?

50,000 ft overview:

Rspec: Behavior Driven Development Framework. It is essentially a different approach to testing than the test/unit (which Rails uses by default). In Rspec you are more interested in testing the side effects of your code, i.e. its behavior, you are less concerned with the internals. This doesn't mean you should write huge methods, and in the end your specs and tests will look pretty similar. My company uses Rspec on our main project.

http://gist.github.com/649417

People will argue the value of the different styles until they're blue in the face. I liked Rspec's syntax more so thats where I started, but in the end I know both and think they each have their own merits and its probably a total wash. Recently with things like shoulda and other tools both approaches are rapidly converging on the same feature set.

Cucumber: Integration framework. This tests your whole stack end-to-end. Depending on what you are building this may be the only way to test it, and for a lot of people they are just doing Unit + Integration tests and not writing any controller tests. You write in Gherkin (http://github.com/aslakhellesoy/cucumber/wiki/gherkin) which is a special subset of English. You can also use Steak (http://jeffkreeftmeijer.com/2010/steak-because-cucumber-is-f...) which lets you write your story in pure Ruby. Either way, this story is broken out in to steps and then some driver follows those steps, either driving or emulating a web browser. The original driver was Webrat, which you can think of as a web browser in Ruby. Webrat has been replaced by Capybara which is more complete and has pluggable backends, including Selenium. If you aren't using much JavaScript you can stay in pure Ruby and your tests will be parsing the HTML with something like Nokogiri, this is also pretty fast. If you have complex JS you can actually drive Selenium which in turn will drive a real browser (you can even drive flock of different browsers). Depending on how complex you get this can be a total PITA, so I would start simple with just getting it running in pure Ruby and maybe testing your sign-up form.

Story -> Cucumber -> Capybara -> Selenium -> Firefox... its a lot of layers and as a result can be suuuuuuper slow.

Factories: Instead of pre-loading a database with stuff (fixtures), factories let you write code that returns prepped objects for you. ActiveRecord takes a row from a table and converts it to an Object (Object Relational Mapper - ORM). Say a post from the posts table into a Post object. Factory Girl will just make you a Post object. I much prefer factories because you can actually get a stack trace to figure out where all the data came from instead of shifting between a SQL database, a YAML file, and a Ruby file to find your 'fixture fail'. There are some variations on preferred syntax and Factory Girl supports most of them.

Shoulda: Just some macros to save you typing. Most of them work in both Test/Unit and Rspec. Instead of writing a test like this to ensure there is a validation error if number in't a number:

http://gist.github.com/649419

Just saves you time and typing, at the expense of learning the helpers.

A good test is something that breaks when the code breaks. Start small, test a few 3 line methods and then build up successively higher tests. Read the tests of some projects on github to get a feel for what they're looking to test, and how they approach it. Then just ask a lot of questions.

You can't do better than mhartls book followed by The Rspec Book (Prag prog) to fully grok this concept. You'll have an "a-ha" moment at some point.

I'm by no means an expert but feel free to hit me up and I'll see if I can help: dev@evan.co.nz

You know what I love about HN? Any community gets stuck on stupid memes. We get stuck on "let me give you free help".
Thanks for the generous offer - very timely too since I've been wrestling with Rails 3 for the past week on a relatively simple CRUD app (my username pretty accurately describes my level of programming experience :) ). I might well take you up on it

Can you be reached by email and do you have any experience integrating Rails apps with the Facebook platform?

I am a rails dev with experience using facebook integration. I have only used facebook connect up to this point, but am going to move towards the new graph api soon, which is much much easier to use. You can send me an email, cullen@ridewithgps.com and ask any questions, and I can hopefully give you some tips in the right direction.

I am looking at exploring mini_fb in the next few days (http://github.com/appoxy/mini_fb) for my new project, and for replacing facebooker/facebook connect in my ongoing startup (http://ridewithgps.com) towards.

I am not sure if this falls in line with what you have in mind, but...

I am learning RoR right now. Could I occasionally send you a quick email asking for clarification on something or help if I get stuck?

Please let me know what you think. Thanks for the offer!

I'm a total Ruby/RoR newb, but is there a "right way" of doing things in terms of setting up an environment?

Much like Python and Django has virtualenv/pip?

Getting a good grasp of RVM is the most important tool in this respect. It serves a similar purpose to virtualenv and in some respects pip because it also integrates rubygems.

It also helps to have a decent grasp of git, you'll be using it a lot for installing things and getting resources from the community. Other than that, it's all personal opinion and you'll work out something that works for you soon enough.

I recommend railstutorial.org as the first and most important stop for Rails learning anyway, so you should try following his instructions for setting up an environment:

http://railstutorial.org/book#sec:rubygems

In terms of getting your app in front of the public quickly and easily, you can't look past Heroku. It has an awesome free account and you won't need to start paying until you want to either a) increase your traffic, or b) run background tasks (such as scheduled bulk emails or something like that)

I have run a site called RailsMentors (http://railsmentors.org/) for over a year that links up people looking for help with experienced Rails and Ruby developers that graciously donate their time. I'd love to see you contribute there as well.
Great idea, I will surely register there!

Can you also check my service - http://videolla.com ? It might be great for donation or "paywhatyouwant" based tutorials and screencasts on Rails. (I just got good reviews from Ryan Bates and DHH :) )Maybe we can partner in some way?

Hi....If u guys wanna learn Ruby on Rails then learn it online for an affordable rate. For more info mail me at info@meghanait.com