ruby-on-rails

Rails Routes Question

Hi, Did the rules for Rails Routes changes from Rails 1.2.3 to Rails 2.2.3? I recently upgraded an application and instead of redirecting to the correct page, it now redirects to the main page (or Route page) for that matter. The only thing that I can think of is that the routing rules changed in Rails 2.2.3. Thanks ...

Automate rails.vim

Hi, I use vim(in console) 7.1 for rails developments on OSX or Ubuntu. Here's what I repeatedly do when I edit files of rails. cd RAILS_ROOT vim :Rproject .project Is there a way that the last part is automatically done? For example, I just type 'vim -some_arg' and it automatically triggers ":Rproject .project"? If that's not possi...

how can you view or edit a database created in netbeans?

i'm using Netbeans 6.5 for RoR development. I believe my sqlite3 DB is out of synch with rails migrations. how can I view and manipulate the database (through netbeans or command line)? ...

ImageMagickError unable to read font `(null)': `(null)'

I've been getting this error for a while on my production server (Ubuntu running ImageMagick, Rmagick, etc). From Googling around it seems to be not finding the right fonts to use, and this needs to be set correctly in sudo nano /usr/lib/ImageMagick-6.3.7/config/type-ghostscript.xml When I open up this file it lists a bunch of fonts...

Form retaining values after refresh.

So I've inherited this legacy rails codebase and there's a bug i need to fix where a given form is retaining values (that have not yet been saved to the DB) even after Page Refresh. Use Case: User fills data in form but does not press submit. User Clicks refresh button on browser. The Values in the form are retained instead of refreshi...

Many-to-Many Association To Same Model with ActiveRecord?

I'm following this tutorial which is working splendidly for has_many :through relationships. I've got normal things like category_product working. However, I am not able to conceptualize this situation (nor get it to work): I have a Category that has related Categories. Since every category can have N categories... first off, is this ac...

Why are Rails and Passenger eating up my memory?

I'm on a 256 slice of Slicehost and running Apache and Passenger to host my Rails app. I've had to do the Hard-Reboot often. When I looked at this Passenger memory stat. --------- Passenger processes --------- ** [out :: welcometonewnepal.com] PID Threads VMSize Private Name ** [out :: welcometonewnepal.com] ------------------...

How can we watch the Rails development log?

A member of my team is developing a Rails app on Windows XP. We are finding that when we run the app, either launching it within NetBeans or by opening a console and calling script/server, the Rails development log does not scroll by. There is only the Webrick startup message. The app is definitely running, but when we hit various pages ...

Rails development with v3 merb merger in mind

I'm in the preliminary stages of designing a new web application, and have yet to begin any sort of implementation. The application models a fairly complex domain, and I'd feel more comfortable using tools such as the ruby DataMapper ORM (having using NHibernate in the .net world) than Rails Active Record. I also prefer jquery over proto...

Is environment.rb invoked on every http request?

I'm wondering what file I should use to ensure my initializing code will only be executed once when the application starts up. Is environment.rb the correct file to use or will it be invoked on every http request? ...

attachment fu - file path

how to get 'manually' the path of a file created with attachment fu without calling model.public_filename ? ...

Are there any drawing plugins for RoR or JQuery?

I am writing a web based application using Ruby on Rails. In one of the forms the users would need to draw something with a mouse and label the object with some text. In short, I need a Simple paint like application on which I can draw with a mouse. Write simple text. Store the painted diagram as a file for future editing. Export...

Rails flash message remains for two page loads

I'm using a flash notice in a Rails application, with the following code: flash[:notice] = "Sorry, we weren't able to log you in with those details." render :action => :new The flash message renders as expected on the 'new' action, but then it also shows on the next page the user visits (whatever that might be). It should only show on...

Array of ActiveRecords to JSON

Hi all, I am aware that ActiveRecord provides a to_json method which allows fields to be filtered out of the JSON output using :only and :except. At present I am using the following to format an array from a find as JSON: @customers = Customer.find(:all) ... format.js { render :json => @customers} How would I be able to select the ...

Simple cropping with Paperclip

I would like to crop images on upload using Paperclip to get square thumbs from the center of the original picture. I find out a method in documentation that seems to do exactly what I want: transformation_to(dst, crop = false) The problem is that I can't figure out where to use this method. It would be great to simply pass something a...

Liquid plugin

I am using liquid plugin in my app. While using rails helper methods like form_for,check_box_tag i am getting an error form_for not defined.. Has anybody know how to use rails helper methods through liquid plugin? ...

How do I model this multi-inheritance relationship w/ Ruby ActiveRecord?

Assuming I have 5 tables. Can ActiveRecord handle this? How would you set it up? The hierarchy: Account (Abstract) CorporateCustomer (Abstract) PrivateCustomer PublicCustomer GovernmentCustomer Edit: In nhibernate and castle activerecord the method needed to enable this scenario is called "joined-subclasses". ...

Problem with Aptana Studio & XULRunner 8.1

Hey guys, I recently installed Ubuntu Jaunty and I'm encountering a problem when I try to run Aptana Studio under it. Any interaction with the internal browser crashes the system. I checked the log and after some Googling came to the conclusion that it was crashing due to the incompatibilty with XULRunner 9.0 which is installed on my sy...

How can I create an all-in-one installer for Ruby on Rails application deployment on Windows?

Hi All, I'm in the process of deploying a rails application to Windows machines. I do all of my development with OS X and Linux, but the final app will actually run on Windows machines. That said, my client is looking for an all-in-one Apache(I had to talk him out of IIS)+Rails+Application deployment/installer. He wants to hand all o...

How do you write tr:nth-child(odd) in Sass?

Is this sass code valid? tr:nth-child(odd) :background-color #cccccc Somehow, it does not color my table's alternating rows. ...