ruby-on-rails

How do you log the URL ActiveResource uses?

Rails ActiveResource is awesome ... except for one thing: as far as I can tell, there is no way to see what URL it is using behind the scenes. For instance, let's say I have an ActiveResource called Issue, for a webservice at myIssues.com/issues.xml. If I do: Issue.find(:all, :params => {:page => 2}) I would expect that ActiveResour...

Rails 3, belongs_to, has one? For 3 models, Users, Instances, Books

I have the following models: Users (id, name, email, instance_id, etc...) Instances (id, domain name) Books (id, name, user_id, instance_id) In Rails 3, When a new book is created, I need the user_id, and instance_id to be populated based on the current_user. Currently, user_id is being assigned when I create a new book but not instanc...

:select with find_in_batches in rails

How can I include a :select clause with find_in_batches. The following throws an error " Mysql::Error: Unknown column 'users.id' in 'field list': . Post.find_in_batches(:batch_size => 100, :select => "users.id, users.name, categories.name, posts.id", :include => [:user, :category]) do |group| #stuff with group end ...

RoR random four users

Hi, Does anyone know how I could display a list of 4 random users in RoR. I know there is the rand() method, but I would have to apply this to an array somehow. ...

Rails (or Ruby): Yes/No instead of True/False

I know I could easily write a function and put it in the application controller, but I'd rather not if there is something else that does this already. Basically I want to have something like: >> boolean_variable? => true >> boolean_variable?.yesno => yes >> boolean_variable?.yesno.capitalize => Yes is there something like this already...

Where do you put your rails app on your server? What User do you deploy with?

I've always deployed my apps to ~/apps/myApp/current (with Capistrano, that's why I have the current directory). But I've seen users deploy to like /var/www/, or even some make a directory at the root, /myapp. I'm wondering is there an ideal place to put my app? Or does it not matter at all. Additionally what do you usually name your ...

belongs_to, can Rails 3, have 1+ foreign

Possible Duplicate: Rails 3, belongs_to, has one? For 3 models, Users, Instances, Books I have a book table (id, name, user_id, instance_id) both user_id and instance_id are foriegn keys. user_id belongs to instance_id. When a new book is created I need both user_id and instance_id assigned. Is that way to do that, in th...

Is it possible to specify two root pages in Rails (one for anonymous user another for logged in user)

I am building a product that has static pages and dynamic pages(product related). Both category of pages have different release life cycle. The marketing team working with the designer, release the static pages and the product pages are released by the engineering team. The static pages reside in public/home and they are self contained....

before_filter: is it possible to specify controller for action?

I'm having the following string in my application_controller: before_filter :login_required, :only => [ :edit, :update, :show, :index ] But in case with :show, I need to put {:controller => 'users', :action => 'show'} in exception. Is it possible to do that? ...

Model View Referencing Another Model View

Hello, I have an Article model and I also have a Comment model. My article show page is rendering a view from the Comment views. It is rendering a new comment form and a show comment form. If I reference a variable in the comment form, like @comment, does it look for the @comment in the article controller or does it look for it in the co...

Tools for Testing a web app (developed with Ruby on Rails / Mongo DB)

I am writing a web application with ruby on rails. It uses mongo db as well. I have a few questions: Firstly, what are the available testing tools (preferrably, free/open-source) for testing web-apps written in ruby on rails. Secondly, what are the testing areas that should and can be generally covered with the above tools (unit, func...

Trying to use polymorphic relationship between comments and models

Hello, I am following a railscasts guide ( http://asciicasts.com/episodes/154-polymorphic-association ) for making comments for different models, but I have run into a problem. When I try to go to localhost:3000/articles/id/comments/new, I get the following error: undefined method `comments_path' for #<#<Class:0xb608b40>:0xb607a60> I...

RoR display records from table other than current users

hi.. their is a table called Colors @user = User.find(currentuser.id) @user.colors, displays all the colors of current_user but, I want to fetch the colors of all other users apart from current user's please, tell me what will be code like I tried like, @c = Color.find(:all), this displays all the records Is there any condition t...

Cannot enqueue items which do not respond to perform -- delayed_job on heroku

Hi, I am trying to use delayed_job on heroku and I get the following error: Cannot enqueue items which do not respond to perform I am using the plugin http://github.com/pedro/delayed_job I am using the following cron rake task (cron.rake): task :cron => :environment do require 'heroku' puts "starting the cron job at #{Date....

Which web technology[ies] should I learn?

Hey guys, I have never done any web development but am very interested in learning some web technologies. I believe I have a fairly solid understanding about programming, so I think picking up different languages/technologies shouldn't be too difficult. I am a junior in college, majoring in CS, and would like to work on a couple of smal...

nested forms using accepts_nested_attributes_for awesome_nested_set

I would like to get full nested (multiple levels) forms working with awesome_nested_set. Currently I've got one level working by adapting Ryans example from his Railscast: http://railscasts.com/episodes/197-nested-model-form-part-2 In my test app I have categories and I would like to go three levels deep eg: Categories -- Sub Category ...

Searching ActiveRecord timestamps using a optionally specific date

Given the following route: match "/articles/(:year/(:month/(:day)))" => "articles#index", :constraints => { :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/ } And the following set of URLs: /articles/2010 /articles/2010/09 /articles/2010/09/08 Does ActiveRecord offer any sort of built-in find method that would allow me to find ...

How Rails app can find out which OS it's running on

Some of development is done on Linux, some on Windows. Depending on which OS the app is currently running on, it needs to load different config files. Is there any "Rails way" to do so? Thanks, ...

jquery dialog ajax load

I am trying to load a form into a jquery dialog via ajax and I notice that for some reason in firebug, the request url contains soem bogus parameter..like.._=1283928792723, which causes the request to fail with a 406 not acceptible. Interestingly enough this does not happen with other routes such as edit_user_path(current_user), but it ...

Can I attach a named scope to a link in Rails?

I have an events model which has two named scopes: class Event < ActiveRecord::Base scope :future, lambda { where('events.date >= ?', Time.zone.now) } scope :past, lambda { where('events.date <= ?', Time.zone.now) } end I call these scopes from my controller by creating two new controller actions (named "future" and "past"): My c...