ruby-on-rails

How to model and store recurring tasks in rails?

Cron solutions in rails are numerous and pretty good. That's not what I'm struggling with here. Instead, what I'm having trouble with is letting users create their own recurring tasks (like reminders) - specifically how to model and store these in the DB (a good UI for it is non-trivial too - would be awesome if there was code out ther...

Rails Nested Route For Singular Resource

I have a nested route on a singular resource map.resource :account, :controller => "users" do |page| page.resources :feeds end I'm trying to make a form to add a feed. I start with this... <% form_for @feed do |f| %> undefined method `feeds_path' for #<ActionView::Base:0x2123174> So I try <% form_for [current_user,@feed] do |f|...

Can't get value params[:user] first request using mongrel_rails start?

I get nil from params[:user] in create action of my controller for the first request when I start my mongrel server by using mongrel_rails start. After that for second and third time are ok. In addition, if I start my Mongrel by using script/server, it doesn't have any problems at all. It is different by starting mongrel server between s...

Rails, working with named_scope

Hello, I need to select some dynamic price ranges submitted from a search form. How should I approach this with scopes? I am looking for something like this Painting.price_range(['1..500', '2000..5000']) SELECT * FROM paintings WHERE price BETWEEN 1..500 **OR** BETWEEN 2000..5000 etc. Best regards. Asbjørn Morell. ...

What is the best way to organize automatic payout at the website?

I have Ruby on Rails application. I can get money from users cards using ActiveMerchant. Now I need to make payouts to the some users based on application logic. For example, Get 10$ from Andrew Get 10$ from Mark Get 10$ from Mike ... application magic that finds who should get money ... Pay 30$ to Mark Generally, I can use not only...

How to keep data when run test in rails

Every time I run test. Rails will delete my data from table. I have million of record in my table for testing search performance and corrective. I can't add data every time I run test. How to tell rails "Please don't delete data in this table" when i run test. ps. I found this link http://stackoverflow.com/questions/433724/how-do-i-...

How to prevent external JS to block your site from loading?

Hi, how do I prevent slow loading external js files from blocking the loading process of the whole website (because the browser processes 2 requests only at a time)? Let's say I want to include the sharethis button but the server is encountering heavy load and needs to long to serve my request, how can I force the rest to load anyway. ...

How can I modify Rails' config within an engine plugin?

I'm working on an engine for Rails as a plugin. I'd like it to be able to make necessary changes to Rails' configuration when it's loaded so it can specify its Gem dependencies as well as add some load paths. The plugin's init.rb file has access to the config object but this is effectively read-only, you can specify a gem but it makes n...

Why keep a copy of an app on the DB host?

A lot of Capistrano example recipes include a :db role. By default the deploy task exports the app code to all hosts in all roles. So that suggests that it's typical for people to keep a copy of their app on the DB host. Also, in Capistrano's distributed deploy.rb recipe, :deploy:migrate looks like this: task :migrate, :roles => :db, :o...

Rails nested resource issue

I have a couple of resources, a grant_application, and a household which are related with a has_one class GrantApplication < ActiveRecord::Base has_one :household, :dependent => :destroy end class Household < ActiveRecord::Base belongs_to :grant_application end ..and I also use the following route.. map.resources :grant_applica...

Why is attribute not saving in Rails?

I've added an "account" variable to a Rails app I'm running, and tested in the development environment with a mongrel server. Everything worked fine. I set my environment to production and use our Apache server, and suddenly nothing works. After a lot of debugging, I've found that the account variable is succesfullying being SET in my me...

Behind the scenes: How does an ORM "think"?

I'm interested in some of the design behind Rails ActiveRecord, Doctrine for PHP (and similar ORMs). How does an ORM manage to accomplish features like chained accessors and how deep are they typically expected to work? How does an ORM construct queries internally? How does an ORM manage the queries while sustaining the arbitrary natur...

Best practice: Multiple categories - best plugin for it (acts as taggable, acts as tree,...)

Hello, I'm trying to find the best solution: I have a usermodel and the user should be able to save the keywords (multiple contexts) which he is interested at. F.e. User-interessts: Sports: Checkbox(CB) fishing, CB Skyying, CB Tennis, CB Soccer Music: CB Metal, CB Techno, CB Folk, CB Charts, ... and so on... After the user saves...

How do I install rails on a Windows machine that uses a proxy server to get to the internet?

I'm a big fan of the ruby way. However today it got in my way. The defacto way of installing rails (i'm running as a domain user on a WinXP machine) is download and install ruby (one-click installer) type >gem install rails at the command prompt Step 2 fails with some function getaddrhost not able to function. Some googling taught m...

Setup Factory Girl with Test::Unit and Shoulda

I'm trying to set up Factory Girl with Test::Unit and Shoulda in Ruby on Rails. I have installed the gem, created my factory file under the test/factories directory, and created my spec file under the test/models directory. The current error I'm getting is 'ArgumentError: No such factory: test', which leads me to believe that the test_fa...

What is the best way to implement user login in Rails?

I am starting a new Rails project and I need to implement a login system that is secure because the application will be dealing with health data. What is the best way to lock down the app in rails? ...

Single Table Inheritance (STI) column associations

When using single table inheritance does one have to be careful not to populate the columns which are specific to different models? Is there a way to specify which columns each model uses? ...

Trackback implementation: rel="trackback" vs RDF

Hi, I want my Rails App to parse external websites for a trackback URL but I'm not really sure if I should just look for a <a href="url" rel="trackback">Text</a> or follow the RDF specifications described by sixapart. Or both. Wordpress and Techcrunch both only offer a rel="trackback" link and they should know. On the other hand may...

Supporting Mobile Devices in Ruby on Rails

What is the best way to develop a rails application that has special views for different mobile devices? Basically I'm looking for something like this ASP.NET MVC solution: http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx ...

How best to sanitize rich html with rails?

Hi there, I'm looking for advice on how to clean submitted html in a web app so it can be redisplayed in future with out styles or unclosed tags wrecking the layout of an app. On my app rich HTML is submitted by users with YUI Rich text editor, which by default runs a few regexps to clean the input, and I'm also calling the [filter_M...