ruby-on-rails

Javascript error in rails app (locally run)

Hi, I am trying to move a development environment from production to my local machine (Ubuntu), and when I get the code up and running on my box, the site works in rails but I get this JS error: Permission denied for http://ad.doubleclick.net to call method Location.toString on http://localhost:3000. Line 0 Do you have any idea how ...

Problem extracting text from RSS feeds

Hi, I am new to the world of Ruby and Rails. I have seen rails cast 190 and I just started playing with it. I used selector gadget to find out the CSS and XPath I have the following code.. require 'rubygems' require 'nokogiri' require 'open-uri' url = "http://www.telegraph.co.uk/sport/football/rss" doc = Nokogiri::HTML(open...

Rails testing: assert render action

How can I write a test to assert that the action new is rendered? def method ... render :action => :new end I'm looking for something like the lines below, but to assert that the action was called, not the template: assert_equal layout, @response.layout assert_equal format, @request.format I know I can't do @response.action Th...

Cannot generate migrations on rails 2.3.4

I used to work with rails 2.3.2 before and then I decided to upgrade to version 2.3.4. Today I tried to generate a migration(I could do this fine with version 2.3.2) and I got the following error message: C:/Program Files (x86)/NetBeans 6.8/ruby2/jruby-1.4.0/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:812:in `const_missing': ...

How can I get my app running with InstantRails 1.0 on windows

I'm trying to get my application to run on InstantRails 1.0. The application works fine using WeBrick, but when I try to run it using Apache in InstantRails, I get: [Wed May 26 12:26:53 2010] [error] [client 127.0.0.1] couldn't spawn child process: c:/instantrails-1.0/rails_apps/guest/public/dispatch.cgi In the apache error log, and ...

Is there a combined Ruby / Rails online documentation?

There are a number of resources online that host Rails and Ruby documentation in various forms and styles. A number of them are good, but none of them document the modules and classes with the methods available from the numerous extensions provided by ActiveSupport and others. For example, with the Standard ruby Hash class, the core ru...

Rails: Multiple "types" of one model through related models?

I have a User model in my app, which I would like to store basic user information, such as email address, first and last name, phone number, etc. I also have many different types of users in my system, including sales agents, clients, guests, etc. I would like to be able to use the same User model as a base for all the others, so that ...

What's the proper way to override Rails ActiveRecord creation/deletion events in a subclass, such as after_create

Hi, I have a class heirarchy as follows: class A < ActiveRecord::Base after_create { |i| #do something } end class B < A after_create { |i| #do something else after what A did } end I want to have A's behavior performed in B when after_create is invoked, but I am not sure of the proper way to write the after_create me...

Limiting a search to records from last_request_at...

I am trying to figure out how to display a count for records that have been created in a table since the last_request_at of a user. In my view I am counting the notes of a question with the following code: <% unless @questions.empty? %> <% @questions.each do |question| %> <%= h(question.notes.count) %> end end This is happeni...

Facebooker2 template issue

Hi, When i include fb_connect_async_js javascript helper it is throwing an error , Facebooker 2 don't have action view template. Could you please tell me how handle this situation . undefined local variable or method `fb_connect_async_js' for ActionView::Base Thanks, Srini ...

How can I install Ruby on Rails 3 on OSX?

Hey i got an White Macbook and, has to go in 10 hours to a conference. And I'm having a lot of problems. First, I wanted to have Rails 3, so I used MacPorts to install Ruby 1.8.7. It worked well ;) So now I was thinking I should install Rails 3.. but no, no!.. it says.. $ sudo gem install rails --pre ERROR:   Error installing...

question regarding rails framework code

I noticed that the code in the rails framework is using the following convention all over the place: class SomeClass class << self def some function end end end rather than class SomeClass end def SomeClass.function end and class SomeClass def self.somefunction end end What is the reason for this design choice...

How do I pass an argument to a remote function when the argument value is not known until after render?

My html.erb template has this: function f(arg) { <%= remote_function :url => { :controller => "the_controller", :action => "the_action" }, :update => 'the_div', :method => :post %> ;} I'd like to do something like :id => arg or :with => "'arg=...'" ... but I don't know what the value of arg is until after the page has rendere...

Can you tell me about a decent ruby gem that I can use for complex joins?

Piggy backing off another question I posted, I have a complex find() that changes whether or not a certain id is nil or not. See here: if self.id.nil? blocks = AppointmentBlock.find(:first, :conditions => ['appointment_blocks.employee_id = ? and ' + '(time_slots.start_at between ? and ? or time_slots.end_at bet...

Keep form fields filled after an error (RoR)

After validation, i got error and return back to :action => :new. Some field on form already filled, so i want to keep them filled afterr error message too. How it can be done? Thanks. ...

application.js in rails

Hi...Where am I supposed to create the application.js file in rails. Inside javascripts directory? Thanks ...

Rails Fixtures vs. Mocks

Hi there, I'm developing a Rails app, and I was just talking with my colleague that we have a mix of fixtures and mocks in our tests, which we're doing using cucumber and Rspec. The question would be: when should each one be used? ...

Can I stop the page from 'scrolling' back to the top when a user clicks on a tab (with Rails not Javascript)?

Ive built a webpage with 'tabs' using rails. When a user clicks a tab, a new page loads. I want to format it so the tabs are always in the same place on the page as a user clicks them. This happens as long as the user has not scrolled down on the page. If a user has scrolled down, clicking on the tab will refresh the page and it is no l...

How to use acts-as-commentable-with-threading in Rails

Hi All, I am developing my first rails site (yup, i am a rails idiot). I'm writing a blog, and i got to the comments part. I installed acts-as-commentable-with-threading ( GitHub ), i made and ran the migration like the install instructions said. I have added acts_as_commentable to my Posts model and i have a Comments controller When i a...

page.insert_html not rendering partial correctly

The following is in the text_field. = f.text_field :title, :size => 50, :onchange => remote_function(:update => :suggestions, :url => {:action => :display_question_search_results}) The following is in display_questions_search_results.rjs. page.insert_html :bottom, 'suggestions', :partial => 'suggestions' Whenever the user types, I'...