ruby-on-rails

Installing Mocha 0.9.7 in a Rails 2.3.3 project

I installed the Mocha 0.9.7 Rails plug-in using: $ script/plugin install git://github.com/floehopper/mocha.git (Just followed instruction in http://mocha.rubyforge.org/) Then, I have the following set-up defined in my functional test def setup @controller.expects(:logged_in?).returns(true) @controller.expects(:admin_user?).retur...

What is involved with changing attachment_fu's storage scheme?

I have a rails application that is using attachment_fu. Currently, it is using :file_system for storage, but I want to change it to :s3, to allow for better scaling as more files get uploaded. What is involved with this? I imagine that if I just switch the code to use :s3, all the old links will be broken. Do I need to just copy the e...

Why are 'session' and 'params' available as local variables in the view but not 'errors'?

I can write: <%= debug(params) %> <%= debug(session) %> but not: <%= debug(errors) %> Why is the errors variable not available locally in the view? ...

What is the best strategy for handling large file upoads with Ruby on Rails?

I'm looking for effective strategies to handle large file uploads (between 10 and 40 mbs) effectively with Ruby on Rails. Ideally I'd like to implement a progress meter and some sort of notification when the transfer is complete. I have looked at modporter (www.modporter.com), but I'm interested to know if there are other libraries, t...

Ruby on rails: Rake Migrate Help

I'm trying to do a rake migrate, but I'm getting an error when I do this: rake db:migrate What I get back: rake aborted! No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb) /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2377:in `raw_load_rakefile' (See full trace by running task with --trace) How do I ...

Handling Non-User data in Rails tests

We have a ton of non-user data: 500 product types that haven't changed in 20 years, 200GB of geospatial data that never changes (Queens is always 40.73N/73.82W)... etc. It's the same in Development and Production. It should be the same in Test, but the during testing Rails empties all of the test tables, and it takes a ton of time to r...

How can I update has_many :through join model attribute in Rails?

I have a model Group and model User They are connected both directions with "has_many :through => groups_users" groups_users table has an attribute, called moderator, specifying whether a user is a moderator of the group when i am trying to update join module attribute, i get a mistake way i am doing it now: @group_membership=@group...

ruby on rails form_for

I have a calendar_date_select in a view that shows a table listing all the information on a certain phone. I want to add a To: and From: date range that a user can select and update the table in the view. The structure is like this: Usage Controller Detail action in the usage controller that shows the call history from a certain phone. ...

What should I do if my Rails tests don't pass?

I want to start contributing to Rails, fixing patches, submitting my own code etc, and the Rails guide states that the tests MUST run. However, they're currently not and I'm not quite sure what to do. I'm running Mac OS X, Ruby 1.8 and I have all the needed gems installed - what can I do? ...

How do you discover model attributes in Rails

I started my first Rails application last fall and had to put in on the shelf for a few months when paying work sucked up all of my time. I'm now interested in getting back to the project and reading through the code to figure out where I left off. The fact that Rails dynamically creates model attributes at runtime saves a lot of repet...

skipping after_update callback

I have a model that uses after_update to log changes. There is a case where I would like to make a change to the model without activating this logging mechanism. Is there a way to pass in a parameter to after_update, or skip it all together? I would like a nice solution to this, and am willing to remove after_update if there is a better...

ruby on rails will paginate between dates

In the application there is a default report the user see's listing all the calls for a certain phone. However, the user can select a date range to sort the list from. Doing that, everything works correctly, but when the user selects the date range and changes to the second page, the date-range is lost and it goes back to the default vie...

Accessing values of elements in RJS

In Ruby on Rails I am working with an inline RJS and trying to find out which select option was selected by accessing selectedIndex property. For some reason unable to get this to work. So, for example assigning / altering the selectedIndex property works great: page['model_author_id'].selectedIndex = 5 But reading it and doing a co...

Opposite of Time.now.advance() in Ruby

http://rails.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Time/Calculations.html#M001139 documents a method advance() to add to the current time. Is there an opposite, 'go_back() method? ...

Add events to anchors when using link_to and :method => :post instead of inline javascript?

So I'm jumping into Ruby on Rails with Agile Web Development with Rails. I got to the part where you use: <%= link_to (image_tag(product.image_url), {:action => :add_to_cart, :id => product}, :method => :post) %> In an attempt to be RESTful, Rails kicks out this inline javascript on each anchor tag onclick="var f = document.createEl...

Ruby on Rails + Sql Server 2005

This has been addressed some time ago, but I've not had any luck following the steps outlined or advice suggested. Here's my situation: I've installed SQL Server '05 and have another (non-Ruby) application utilizing it successfully. I've got Rails up and running successfully (but only for MySQL.) I've installed the Rails sqlserver adap...

ruby on rails / routing-filter / form_for changes html

Hi, this question is related to routing-filter. I have this in my view: <% form_for :post, :url => {:action => "show"} do |f| %> which translates in the browser to this: <form action="/en/posts/show" method="post"> after changing the I18n.locale e.g. I18n.locale = :en the html becomes: <form action="/en/posts/72" method="post"...

Phusion Passenger with Ruby 1.8 and 1.9 ?

Hi, How would I go about running two separate Rails applications using Phusion Passenger with one using Ruby 1.8.x and the other using Ruby 1.9.x ? I'm running Redmine which isn't Ruby 1.9.x compatible, and the other application is a home grown app. I'm using Apache 2.2.x with Passenger 2.2.4. Is this even possible ? ...

Inconsistent behavior of Time.now in Ruby/Rails app

I have a Ruby on Rails app that has a scheduled job I execute using cron and script/runner. The purpose of the job is to find any updates that are past due ('stale', see below) and (after executing the job) update the 'due date' of the job a pre-defined number of minutes into the future. The problem I'm having is that when I set the 'd...

Authlogic openid with multiple openid identifiers per account

How would you go about allowing a user to log in with multiple openid accounts and optionally a password, using authlogic? ...