ruby-on-rails3

Performing an action in Rails at a specific time

Guys, Is there a way to setup a callback in ROR that would trigger at a specific time? Lets say I'm running a contest that expries at a certain time. Lets say Monday July 28th at 9:00. I'd like to set up an observer that ran a function at Monday July 28th at 9:00. Does rails have a method to do this? ...

Rethinking relational many-to-many relationships for MongoDB

I am just starting a new Rails 3 project using Mongoid ORM for MongoDB. There is just one thing I can not get my head around, and that is how to effectively have a many-to-many relationship. Now there is a good chance that I may be approaching this problem wrong, but as far as I know, there is at least two containers in my project that...

Rails3: linking to offsite mp3 files and have them save to user's hard-drive rather than stream in the browser

I have some very large mp3's stored at a remote location and I presently link to them like so: = link_to "mp3", "http://website-where-file-is-stored.com/file-123456.mp3" When a user clicks the link, the file starts to play in the browser. I would like the file to download to the users hard-drive after they click the link. I've read a...

How can I simply verify that a username and password are correct with Devise and Rails 3

I am using Devise and Rails 3. I want to perform a function that will simply verify that a user's username and password combination is correct without actually logging in that user. Is there some way I can accomplish something like User.authenticate(params[:username], params[:password]) with Devise? ...

Current trend in testing models in a rails3 + datamapper application

Hi, What is the current trend for testing models in a Rails3+DataMapper application. I want to use RSpec but sorely miss the concise testing provided by shoulda macros. Question - Is there a way of getting the best of both worlds, ie. a nice dsl for testing and the brevity of shoulda macros, which can be used to test datamapper models. ...

Lookup Gem or Plugin code packaged in a Rails3 application

In the Rails2 world, one could conveniently browse the code of plugins or gems packaged with the app. With Rails3, all the packaged gems are stored as .gem and hence are not browsable or searchable. Now I have to use 'bundle open [gem]' externally to browse gem/plugin code. Does anyone have a better technique to lookup or read gem/plugin...

format.js argument

Hi all, I've a question about passing argument with format.js There's my code (create method): respond_to do |format| format.js end I would like to know how can i get a variable value in my create.js.erb Thanks ...

Passing cucumber options with Autotest and Bundler for Rails3 app

Hi, I'm little confused on how to use cuke's options. I know that I can run spec and cucumber in two different console. But I want it to run both. So, I can pass args/options for rspec like bundle exec autotest -c -f specdoc but if I pass cucumber options like --tags @wip --format pretty, it blows out. So, how can I accomplish this?? ...

Rails 2 vs. Rails 3

DHH recently stated that Rails3 is about to be in RC mode. This announcement ironically coincides with me and a friend of mine starting a Rails application. At this point in the game, we were going to just go ahead and be early adopters of 3. However, as we're both fairly inexperienced in creating large web apps with Rails, 2 seems like...

Rails 3, RSpec 2, and Cucumber yields wrong number of arguments (3 for 1) (ArgumentError)

I mostly followed these instructions to get things spun up: http://lindsaar.net/2010/5/9/Getting-Rails-3-Edge-with-jQuery-RSpec-and-Cucumber-using-RVM If I create a completely blank .feature file, running cucumber results in this error: cucumber wrong number of arguments (3 for 1) (ArgumentError) /gems/gherkin-2.0.2/lib/ghe...

multiple CSS class/id names using Ruby on Rails 3 form helpers

I am attempting to pass 2 classes to an element in a rails 3 application and having some issues with encoding. <td class="edit"> <%= link_to 'Edit', edit_link_url(link, :class => 'edit_link ui') %><br /> <%= link_to 'Delete', link_url(link, :class =>'delete_link ui'), :confirm => 'Are you sure?', :method => :delete %> </td> c...

Why am I getting a "SystemStackError: stack level too deep" in my rails3 beta4 model

Hi there. I'm getting the following error: SystemStackError: stack level too deep when executing the following code in rails3 beta4 under ruby 1.9.2-rc1: ruby-1.9.2-rc1 > f = Forum.all.first => #<Forum id: 1, title: "Forum 1", description: "Description 1", content: "Content 1", parent_id: nil, user_id: 1, forum_type: "forum", create...

Rails3, cucumber problem

Trying to follow this tutorial. Autotest fails with this error message: sg $autotest loading autotest/cucumber_rails_rspec2 Error loading Autotest style autotest/cucumber_rails_rspec2 (no such file to load -- autotest/rails_rspec2). Aborting. Gem list: abstract (1.0.0) actionmailer (3.0.0.beta4) actionpack (3.0.0....

Any tutorials for Facebook Connect and Rails 3?

Are there any tutorials out there for setting up a new user in my Rails 3 app using Facebook Connect? Thanks! ...

button_to_remote using jQuery and Rails 3

Is this possible given the button_to_remote function seems to be defined as a Prototype helper? I've replaced my /public/javascripts/rails.js with the jQuery driver. When I try to use button_to_remote I get the error undefined method 'button_to_remote' for #<#<Class:0x000001078d7090>:0x0000010789ad20> If this is not possible using butt...

Is it possible to use modify nginx config file and use X-Accel-Redirect on Heroku?

Reading this article on nginx website, I'm interested in using X-Accel-Redirect header in the way that Apache or Lighttpd users might use the X-Sendfile header to help with the serving of large files. Most tutorials I've found require you to modify the nginx config file. Can I modify the nginx config file on Heroku and if so, how? ...

Ruby on Rails 3 - Reload lib directory for each request

Hey guys, I'm creating a new engine for a rails 3 application. As you can guess, this engine is in the lib directory of my application. However, i have some problems developing it. Indeed, I need to restart my server each time I change something in the engine. Is there a way to avoid this ? Can I force rails to completely reload the ...

Setting a class on a rails select

I need to set an HTML class to this rails select and i have tried many variations and nothing <%= add.select :state, @states.map { |s| [ s.name, s.abbr ] }, :class => 'state', :include_blank => true %> ...

How do I add a route from within a Rails App

Hi I'm writing a spec and i need to setup a test route from inside the spec however when i use Rails::Application.routes.draw it overwrites all the other routes. Is there a way to do this in rails 3? Cheers Dan ...

Rails3 nested-routing issues

I would like to create a mechanism for a User to keep track of other, favorite Users, similar to SO's favorite questions. I'm using the Rails 3.0 beta. To do so, I have a User-Favorite HABTM relationship, which works as expected: class User < ActiveRecord::Base has_and_belongs_to_many :favorites, :class_name => "User", :join_table =...