ruby-on-rails

acts_as_tree does not destroy the model's children

I have this Task model: class Task < ActiveRecord::Base acts_as_tree :order => 'sort_order' end And I have this test class TaskTest < Test::Unit::TestCase def setup @root = create_root end def test_destroying_a_task_should_destroy_all_of_its_descendants d1 = create_task(:parent_id => @root.id, :sort_order => 2) d...

Stick with PHP or learn Ruby (on rails)

Hi, I am a CS student and I wanted to get some more experienced folks' opinion on the following: I have a strong background in the curly bracket languages, particularly C and Java, and have been working with php for about a year now and again. I am also currently interning at a PHP shop. My goal is to hopefully get a job in web develop...

Ruby on Rails Editor for Windows

I love to use Textmate on my Mac at home but have a hard finding somehing to use at work (windows). What is the best editor to use for Ruby on Rails on windows that get you the closest look and feel to Textmate? ...

What does a db table created by the Rails framework look like?

I don't have a Rails environment set up and this is actually quite hard to find a quick answer for, so I'll ask the experts. When Rails creates a table based on your "model" that you have set up, does Rails create a table that mirrors this model exactly, or does it add in more fields to the table to help it work its magic? If so, what ...

Recursive Rails Nested Resources

I have a Rails application for project management where there are Project and Task models. A project can have many tasks, but a task can also have many tasks, ad infinitum. Using nested resources, we can have /projects/1/tasks, /projects/1/tasks/new, /projects/1/tasks/3/edit etc. However, how do you represent the recursive nature of ta...

rails in_place_edit: how do I pass an authenticity token?

I am trying to get in place editing working but I am running into this error: ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken) I understand that rails now wants to protect against forgery and that I need to pass a form authenticity token but I am not clear on how to do this with the in_place_edit ...

Designing Web Sites with Ruby on Rails

I'm just learning Ruby on Rails. I've read a few books, I've watched lots of Railscasts, I've looked at some examples. However, when working on my first serious project with Rails, I've gotten hung up on how to properly implement some very basic web site features that most tutorials I've seen lack. For instance: Navigation menus. Lots...

How to find where a ruby method is defined (at runtime)?

We recently had a problem where, after a series of commits had occurred, a backend process failed to run. Now, we were good little boys and girls and ran rake test after every check-in but due to some oddities in Rails' library loading, it only occurred when you ran it directly from mongrel in production mode. Tracked the bug down and i...

How do I change the index page for rails?

I know that to change the index page for rails I need to do three things: delete the index.html, do something with routes.rb, and probably make an action that the route will point to. It's the details that I am a little fuzzy on :-) ...

Object database for Ruby on Rails

Is there drop-in replacement for ActiveRecord that uses some sort of Object Store? I am thinking something like Erlang's MNesia would be ideal. Update I've been investigating CouchDB and I think this is the option I am going to go with. It's a toss-up between using CouchRest and ActiveCouch. CouchRest is pretty mature, and is used in...

ActiveRecord Association caching Date value in conditions clause

My Account model has the following two associations: has_many :expenses, :order => 'expenses.dated_on DESC', :dependent => :destroy has_many :recent_expenses, :class_name => 'Expense', :conditions => "expenses.dated_on <= '#{Date.today}'", :order => 'dated_on DESC', :li...

What scares you the most about the integrated IDE of most modern Smalltalks?

As I'm riding the wave of resurgence of Smalltalk (especially because many Ruby-on-Rails people are rediscovering Smalltalk and seeing Seaside as their next upgraded web framework), I get questions like "yeah, but how do I use my favorite editor to edit Smalltalk code?" or "Does Smalltalk still insist on living in a world of its own?". ...

jQuery: how to change title of document during .ready() ?

I am using some nested layouts in Ruby on Rails, and in one of the layouts i have a need to read in a string from a div and set that as the title of the document. What is correct way (if any) to set the title of the document? <script type="text/javascript"> $(document).ready(function() { // ??? }); </script> ...

How can I copy a mySQL Database in ruby on rails?

We are making a Ruby On Rails webapp where every customer gets their own database. The database needs to be created after they fill out a form on our website. We have a template database that has all of the tables and columns that we need to copy. How can I do this in programatically from ruby on rails? ...

What are the limits of ruby on rails?

I have a memory of talking to people who have got so far in using Ruby on Rails and then had to abandon it when they have hit limits, or found it was ultimately too rigid. I forget the details but it may have had to do with using more than one database. So what I'd like is to know is what features/requirements fall outside of Ruby on R...

How can I dynamically change the Active Record database for all models in Ruby on Rails?

In our program, each customer gets their own database. We e-mail them a link that connects them to their database. The link contains a GUID that lets the program know which database to connect to. How do I dynamically and programatically connect ActiveRecord to the right db? ...

JQuery selectors not finding class on elements in table created by an Ajax XHR in Ruby on Rails

When using $('.foo').click(function(){ alert("I haz class alertz!"); return false; }); in application.js, and <a href = "" class = "foo" id = "foobar_1" >Teh Foobar </a> in any div that initializes with the page, when clicking "Teh Foobar" it alerts and doesn't follow the link. However, when using the same code in a...

Ruby on Vista

I installed Ruby and Ruby on Rails yesterday on Vista 32bit using the directions on this site: http://rubyonrails.org/down so I downloaded the installer, then Gems, then I downloaded rails with Gems. now I can't use the Gem or Ruby commands in the command line... so I assume there's something wrong with the environment variables, but I...

Best way to add full web search to my site?

I need to add full web search to my site. I need something like Google Custom Search but with no ads and it has to be free. Any recommendation of a web service or open source project that can index my site and allow me to search it will be helpful. My site is made in ruby on rails, if that helps. I'll make this question community-wiki ...

How can I cache a calculated column in rails?

I have a tree of active record objects, something like: class Part < ActiveRecord::Base has_many :sub_parts, :class_name => "Part" def complicated_calculation if sub_parts.size > 0 return self.sub_parts.inject(0){ |sum, current| sum + current.complicated_calculation } else sleep(1) return rand(10000) e...