ruby-on-rails

Accessing an uploaded file without actually storing it in the database or on the server -- Ruby on Rails

I have a system where the user uploads a file and I have to read the file and display its contents on a form without storing it either on the server side or in the database ...

Memcached always miss (rails)

Hi Stackoverflowers, I have spent way too much time on this issue to keep my sanity so it is time to ask for help... I have a class with this method: def telecom_info Rails.cache.fetch("telecom_info_for_#{ref_num}", :expires_in=> 3.hours) do info = Hash.new(0) Telecom::SERVICES.each do |source| results = Tele...

What's the best way of backing up a rails app data?

I need to make a backup system for my rails app but this has to be a little special: It doesn't have to back up all the database info and files in a single file or folder but it has to back up the database info and attachment files per user. I mean, every one of this backups should be able to regenerate all the information and files for ...

Rails - delete one side of a one-to-many relationship

Quick question: If I have a one-to-many relationship, such as this: class SalesPerson < ActiveRecord::Base has_many :deals end class Deal < ActiveRecord::Base belongs_to :sales_person end how can I delete a Sales Person, without negatively impacting the deals associated with them? The use-case for this would be if someone left ...

cucumber should see button

I have a form that has this <%= submit_tag 'Search Event' %> and a cucumber step that says And I should see "Search Event" but this step fails.. why is that? Here is the error i get expected #has_content?("Search Event") to return true, got false (RSpec::Expectations::ExpectationNotMetError) ...

Changing the timestamp of magic columns (Rails)

I want to change the default timestamp of the magic columns of rails (created_at, modified_at) instead of 2010-09-03 14:52:46 UTC I'd like to change it to September 10, 2010 at 02:52 PM. or at least parse that way. Now, i know that i can do this right in the view, by manipulating the variable, but isnt there a more "railish way" where ...

individual spec passes when run alone, but fails when all specs are run

I have 30 specs in my foo_controller_spec.rb and when I run the entire file using spec, I get 4 failures and 2 pending. When I run the 4 failing specs individually, 3 of them still fail, but one of them passes. At first I thought it was a database issue, that the data wasn't being cleaned out properly between runs. So I installed databas...

Thread tried to join itself

I am working on building a Ruby on Rails v2.3.8 real estate application. I've written a rake task to pull in the property listings and photos. The app uses rets4r (specifically josephholsten-rets4r) to talk to a RETS-based server and Paperclip is used to manage the property photos and push them up to S3. The problem I'm seeing is the ra...

What is the best way of running shell commands from a web based interface?

Imagine a web application that allows a logged in user to run a shell command on the web server at the press of a button. This is relatively simple in most languages via some standard library os tools. But if that command is long running you don't want your UI to hang. Again this is relatively easy to deal with using some sort of backgr...

How can I access rails 2.3.x commands when rails 3 is installed?

I'd like to play around with rails 3, but I'm still used to rails 2.3.8 so I have them both installed. Wanting to make a quick rails app to demonstrate how a plugin works, I want to run the command rails test_app but since I have rails 3 installed, I have to run rails new test_app but that will generate a rails 3 app. Is there a way arou...

Can someone describe to me what RSpec 2 is doing in this?

I have been attempting to dive into RSpec 2 but its auto generated controller specs do not work for any version of RSpec 2 with any version of Ruby or any version of Rails. Maybe I'm missing something obvious? def mock_category(stubs={}) @mock_category ||= mock_model(Category, stubs).as_null_object end describe "GET show" do it "as...

Rails 3 - Testing if View calls a method

Hi, I'm starting to learn Rails. I'm using Rails 3. In my simple App, I have the following code: <% @tasks.each do |task| %> ... <td><%= friendly_estimate task.estimate, { :compact => true } %></td> ... <% end %> The mission for me is that I would like to test if the view really sends the :compact option to my method to ensu...

no such file to load -- activesupport (LoadError)

I can't get the db2s3 gem to run on my rails 3 application. /usr/lib/ruby/gems/1.8/gems/db2s3-0.3.1/lib/db2s3.rb:1:in `require': no such file to load -- activesupport (LoadError) from /usr/lib/ruby/gems/1.8/gems/db2s3-0.3.1/lib/db2s3.rb:1 from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:64:in `require' from /u...

Rails action response should behave like a simple file response - no session or cookies

I have a rails controller I dont ever want to set a cookie. I production, all it's actions are basically page cached and served as static files. But in development it's responses are generated on each request so that we can change things on the fly and test it out. The problem is that when we have parallel requests that change cookie d...

How to cancel scheduled job with delayed_job in Rails?

Title says it all basicly. I am scheduling a job to run in say, 10 minutes. How to properly cancel this particular job without using any kind of dirty extra fields in model and so on. Is there any call to remove particular job, or jobs related to specific model, instance, etc? ...

Ruby/Rails - Problem to build a method with request.fullpath

Hi, I'm trying to build a method in order to add a specific css class to my nav menu on current pages. Here is my start: (in application_helper) def menu_links(param) if request.fullpath == "#{param}_path" return "#{param}_path" end end in my app view: <%= menu_links("help") %> However, if I change request.fullpath == "#{par...

Can i use rak command inside rake task ?

I have install gem rak i want to use rak command inside rake task ... How may i use that ?? I know how to use it on command prompt ... This is working fine on command prompt ... rak RAILS_ENV ...

Save after rename_column in Rails migration

I'm trying to work around Oracle's inability to change the type of a column with data in it. I cache the attribute's correct value, set it to nil, rename the column and then attempt to re-set the attribute: class SwitchToForeignKeys < ActiveRecord::Migration def self.up registration_countries = {} Registration.all.each do |r| ...

How to customize google maps infowindow in rails using ym4r_gm

Hi Friends, I integrated google maps in my rails project using ym4r_gm. I want to customize the infowindow as in trulia.com (http://www.trulia.com/for_sale/New_York … _homes_lt/). I went through the ym4r_gm code to include 'extinfowindow', but no use :( I'm really struggling alot to customize the bubble/infowindow. Can any one expla...

rails nils in a form

This is probably a simple question, but I noticed a few errors deriving from having empty values instead of nils... If a user leaves a field blank in a standard rails app is there a way to leave the field in the database set to NULL instead of entering an empty value? Basically so a check like @model.info.nil? return true instead of ha...