ruby-on-rails

Open Source ruby and rails projects

Which open source ruby or ruby on rails projects do you contribute to regularly? ...

How do you read an existing Rails project?

When you start working on an existing Rails project what are the steps that you take to understand the code? Where do you start? What do you use to get a high level view before drilling down into the controllers, models, helpers and views? Do you have any specific techniques, tricks or tools that help speed up the process? Please don...

My site has to support multiple languages, how do I route in rails?

I have several resources and I want to somehow have a :lang parameter in the header. So /en/posts/ would direct to posts_controller/index with params[:lang] == en. How is this usually done? It looks ugly to have to add ?lang=en on every link and feel very un-railsy. I think you know what I'm talking about even if I'm not very clear, wh...

Ruby on rails count and group!

I have a database with the following schema: t.string "mail" t.integer "country" t.boolean "validated" t.datetime "created_at" t.datetime "updated_at" And I want to find the top 5 countries in the database, so i go ahead and type @top5 = Mail.find(:all,:group => 'country',:conditions => [ "validated = ?" , "t" ...

In RESTful design, what's the best way to support different kinds of GETs?

In a current project I need to support finding a User by login credentials and also by email address. I know that in RESTful design you use a GET to find resources. In Rails... GET /users # => UsersController.index -- find all the users GET /users/1 # => UsersController.show -- find a particular user But I also need something aki...

Can ActiveResource models integrate with ActiveRecord models?

I'm working on a Rails app that will serve as an authentication system for other Rails apps through Rails's ActiveResource functionality. The authentication app has an ActiveRecord model called User. The client app has an ActiveResource model called User. I know that in the client app I can do stuff like user.save and it will perform a ...

How would you model articles with references and citations in rails & ActiveRecord?

An article has many articles that it refers to and many other articles can refer to it. Sometimes an article can refer to an article that also refers to it. ...

How do you validate attachment_fu's image width and height?

I want to be able to validate the image is exactly a certain with or a certain height, or if it's square. In the validation block of the model that has_attachment, when I try to access image_size, width, or height, it always comes out as null. I also asked the question here if you want more details. ...

'WebControls' for Ruby on Rails

I've recently started working with RoR for some projects and I quite like the framework - however coming from an ASP.NET background I'm quite fond of the idea of being able to purchase & drop in reusable components/control such as those from telerik, without having to 'reinvent'. I suppose it would be possible to maybe create my own usi...

Should I heed Derek Sivers' warnings about migrating from PHP to Rails?

As you probably know, Derek Sivers is the guy who created CD Baby and eventually sold it for some big bucks. He wrote it in PHP originally and then down the road set about rewriting it in Rails. His troubles are the stuff of legend: 7 reasons I switched back to PHP after 2 years on Rails That article came out in 2007 but being newly in...

Best plugins and gems for parsing email ala Highrise

I am looking for recommendations on the best Rails plugins and gems for parsing email and inserting it into the database, similar to the way Highrise and Basecamp (among others) work. Described here http://wiki.rubyonrails.org/rails/pages/HowToReceiveEmailsWithActionMailer Are there any that people recommend, currently? ...

Rails 2.2.2 Performance Problem/Bug

I recently upgraded one of my applications to Rails 2.2.2. Having done that, I've encountered a strange performance bug that has caused renders that used to complete in a fraction of a second to take up to 10 seconds. I've profiled the issue, and here are the results I've come up with. It looks like the issue is in the real_connect me...

How do I textile and sanitize html?

Now i ran into some stupid situation. I want the users to be able to use textile, but they shouldn't mess around with my valid HTML around their entry. So I have to escape the HTML somehow. html_escape(textilize("</body>Foo")) would break textile while textilize(html_escape("</body>Foo")) would work, but breaks various Textile features...

Do any big companies use Rails internally?

I keep hearing about Rails being used by startups but have not heard of, say, Morgan Stanley using it. Is there a list somewhere of bigger companies that use Rails internally? ...

Are you using AWSDBProxy? Is there a performance hit when scaling out?

After a down vote, I humbly realized that my post was an enormous rant. So I've edited it and summed this down to just the question I'd really like to know. I apologize for my brash comments prior to this edit ;) It seems that the only tutorials out there talking about using Amazon's SimpleDB in a rails site are using AWSDBProxy... Per...

What is the most active public forum/message board for discussion of Rails implementation issues

I found quite an active discussion on WorkingWithRails but can't tell if this is the most active of the Rails discussion forums? Where do most people go to ask questions? ...

Rails: Scaffold to automatically do one-to-many relationship

Not sure if I'm reading this right, but it seems like Scaffold will not do a one-to-many relationship in its entirety. For instance, if I create messages with scaffold and then I want comments on those messages (one message -> many comments), I have to go through and change everything. For instance, I have to change this in the comment's...

NoMethodError: Using already-defined named route in map.root call

If I try the Root-URL of my Rails-App, I get the following error: NoMethodError undefined method `[]' for :company_url:Symbol # (part of the) content of my config/routes.rb ActionController::Routing::Routes.draw do |map| map.company 'company', :controller => 'companies', :action => 'index' map.root :company_url end But the ...

How to find a record created on the previous month?

I have a table where new records are added daily. How would I go about finding records created in the previous month? ...

change layout on selection box change

Hi all, I want to render a partial depending on a selection in selection box. This looks trivial but I can't find an example. All help is greatly appreciated. Regards ...