ruby-on-rails

Problem with link_to_remote in rails

I'm having a consistency problem using link_to_remote in rails. I have 2 use cases of link_to_remote, and they generate different ajax. I can't figure out why, and it is driving me crazy. Here is use case one... <%= link_to_remote "section-", :update => "sections", :url => {:action => :destroy, :controller => "sections", :id => @sect...

Getting started with Ruby Gem Development

Recently I started using a gem called blackbook. The gem has a few issues that I would like to fix. I cloned the git repo and installed the gem locally, hoping I could mess with the source code. When I edit the source code nothing happens, so now I am thinking that I must rebuild the gem every time I make a change. My question is thi...

Browse location with geokit

Hello, My user model is using geokit to find the address from the ipaddress. How do I let the user select a different country, state or city? (select list) I have checked all the documentation and I can't figuere out how I retrieve a list of countries, states or cities. Best regards Asbjørn Morell ...

How to remove size property from input generated by text_field?

I have an .erb file with form template that uses form_for helper to generate form, and some of their fields generated with text_field method. In resulting HTML I see size properties are added to every input generated with aforementioned method. I want to control input sizes with CSS and that size property prevents me from doing it. Is t...

How to start with Rspec?

I have been into rails for the last 3 months. Now I wish to start BDD or TDD. I want to start with RSpec. How do I start with it? ...

Rails conditional routes

Hello I am trying to set up a user creation wizard where the user can only go to the page that corresponds to the current step in the wizard that the user is on. I have already sorted out the state machine functionality. The current state is stored in the DB. This is not the problem The problem is how to redirect the user to the right...

my_object.save(false) doesn't REALLY skip my Active Record validations

Hey All, So I have been pulling my hair out troubleshooting this bug I have been having, and I finally discovered what was causing it. I had always been under the impression that when I called @my_model.save(false) That I would be skipping my ActiveRecord validations. Turns out this is partially true. My objects are saving to the d...

Rail Validation Error Handling

Hello, Currently when my rails app encounters an error it dumps the error code and stack trace onto the browser window. How do I turn this off so that these error are only recorded in the log and not outputted to the browser? Thank you Correction: I am mostly concerned with only the validation errors. All I want is the same function...

Java: HTTP Post to create new "Product" in a Ruby on Rails application

Using the Apache HttpClient on android, how do I send data to a RESTfull Ruby on Rails app using HttpPost. This is my Controller: # POST /products def create @product = Product.new(params[:product]) respond_to do |format| if @product.save flash[:notice] = 'Product was successfully created.' format.html...

Facebook app profile tab does not display content

I am trying to add a profile tab to my Facebook app. In the Facebook Edit App page, I have set the tab url to http://apps.facebook.com/my-suggestions-tu/pages/test. I only needed to enter "pages/test" in the text field; "http://apps.facebook.com/my-suggestions-tu/" was already supplied by Facebook. I can view http://apps.facebook.com/my...

When to use memoization in Ruby on Rails

In mid July 2008 Memoization was added to Rails core. A demonstration of the usage is here. I have not been able to find any good examples on when methods should be memoized, and the performance implications of each. This blog post, for example, suggests that oftentimes, memoization should not be used at all. For something that could p...

Rails applications' life cycle

I'm trying to learn the life cycle of a rails application. When is application_controller.rb run? Is it just once every time it's changed, or on every request? I want to know the same about the following file: config/environments/*.rb (development, production, or test, depending on the current mode) boot.rb environment.rb routes.rb ...

How to delete the temporary files automatically in ruby-rails?

Hi, My Rails app has to process and generate PDF XFA files and send to the user/browser. Its working fine. But the issue is that before sending the file to the user, it creates 2 files in the rails tmp directory. If 10 requests come to the pdf_controller, the number of the temp files in the tmp directory will double and it will eat up ...

How does class cacheing work in rails 2.2+

I have a rails application that patches ActiveRecord with a hand-coded validator. The patch is made by adding the following lines in config/environment.rb Rails::Initializer.run do |config| ... end class ActiveRecord::Base include MtLib::DBValidations end This works fine in production mode i.e. with config.cache_clas...

Help with Rails routes

Say if I have a controller, profile, which has just two actions. The first one is list, which will just show the list of names. I want these names to be links which will then take you to a page that shows the full profile. So I need a second action, view, which can then bed fed a parameter to indicate which profile to view. For example...

How to consolidate multiple rails application and share ressources

Hi all. I have thi intranet I developped back then with PHP. I handles multiple apps and tools (blog, link sharing, file sharing, events, clendar...), and a big user autenthication system for logging in and authorisation management. I'd like to start re-building it with Rails. I don't want to build one big app. I'd like to build the si...

File upload kills rails app and server

I have simple model which looks like this: def video_file=(input_data) unless input_data.to_s.empty? newfile = File.open("#{RAILS_ROOT}/public/to_upload/#{self.filename}_vid.f4v", "wb") do |f| while buff = input_data.read(4096) f.write(buff) end end end end and here the error which rails manages to disp...

Creating Microsoft Word (.docx) documents in Ruby

Is there an easy way to create Word documents (.docx) in a Ruby application? Actually, in my case it's a Rails application served from a Linux server. A gem similar to Prawn but for DOCX instead of PDF would be great! ...

Polymorphic Associations in Rails

How do polymorphic associations work in Rails? What are their advantages? Is there a way to add belongs_to method just by running a migration? ...

Escaping HTML in Rails

What is the recommended way to escape HTML to prevent XSS vulnerabilities in Rails apps? Should you allow the user to put any text into the database but escape it when displaying it? Should you add before_save filters to escape the input? ...