ruby-on-rails

Prevent Rails app from responding to unintended AJAX request from jQuery

I've built out a fairly complex Rails (2.3.8) app with a lot of jQuery ajax requests. There is an occasional bug, which I have difficultly replicating, where a jQuery $.ajax({..}) request will request a page it shouldn't (like the dash page, which is never called with an ajax request)... What ensures is absolutely madness. Incredibly st...

Ajax form partials in Rails for multiple Models

I have this piece of AJAX code (took from: http://badpopcorn.com/blog/2008/09/11/rails-observer-field/) that is present in many views (new.html.erb and edit.html.erb mostly). To avoid code duplication I pretend to make use of partials: app/views/cities/_state_city_form.html.erb <p> State: <%= select(:state, :state_name, City.all(:sel...

RSPEC configuration problem

I am trying to install RSPEC but after configuring RSPEC gem and RCOV when i try to run rcov user.rb , i get the following error:- /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- spec/example/configuration (MissingSourceFile) Can anybody help? ...

rails: removing underscore from controller name

when I generate a two word named controller, like FooBar rails creates a controller and path like foo_bar this is not pretty. I would like to have the paths at least be FooBar. Possible? Suggestions? ...

Determining current_user with declarative_authorization and authlogic

I use authlogic to authenticate users. In my controllers I use current_user, defined (as documented) as follows: def current_user_session return @current_user_session if defined?(@current_user_session) @current_user_session = UserSession.find end def current_user return @current_user if defined?(@current_user) @cur...

What`s the diff between ruby 1.8.7 and 1.9.1 in module require?

There is a module require 'iconv' module Escape def escape(string) return_value = Iconv.conv('ascii//translit//IGNORE', 'utf-8', string).to_s end end It`s work in 1.8.7 but not in 1.9.1 The error message is "NameError (uninitialized constant Escape::Iconv)" and the follow is work in 1.9.1,Why??????? (my rails is rails 3 in ...

How to parse random/unorganized rss feeds in Ruby/Rails?

Hello, I am facing problems while parsing RSS feeds from different sites. I need to fetch url, title and image from the feeds, but all of the sites have different structure for their feeds. Is is possible to have a generic script to fetch content from feeds of any structure? How do browsers/feed readers/Google Reader handle this situat...

is multiple sitemaps receommendable to a web portal

I have a cricket based portal check here cricket scores This site has near to millions pages. But is it advisable to have a multiple sitemaps in the website or not? if Yes, what Name shall we give for the second site map? sitemap2.xml does this work? Some where in the blog i have read that each sitemap should not have more than 1000 l...

Html5/Javascript frameworks/server side JS Framework vs Ruby on Rails?

My question is if a developer only knows either Html5/Javascript frameworks/server side JS Framework or Ruby on Rails, which skill set will allow him to develop the best web apps or provide greater creativity on the web? Regards ...

ruby on rails Updating multiple partial when using ajax with form_remote_for

I want to update more then one partial using the ajax form_remote_for helper Currently I use this code which can update only one partial form_remote_for :hour, @hour, :url =>{:action => "manage" },:id =>'hoursForm',:update=>'hoursIndex' do |f I will appreciate if someone can tell me how can I adjust the update parameter so it can upd...

How to paginate two tables in one view

Hello,I want to ask if i can use will_paginate plugin two times on one page? For example i have table with male users and table with female users on one page or in one view and I need paginate both tables. My question is what is the usual solution of this problem? ...

SQLite 3 Busy Exception in Rails 2.3.8

SQLite3::BusyException: database is locked: CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email") I get the above error when I try to migrate a migration (written below) class AddIndexEmailUniquenessToUsers < ActiveRecord::Migration def self.up add_index :users,:email,:unique => true end def self.down remove_...

Rails App Maintenence Without Hindering Visitors

A Phusion Passenger error message isn't what I want my visitors to see if they landed on my site while I'm updating the back end. So how do I get around this? Is my deployment process flawed from the start? or is there something I'm missing out? Here's my process of deployment, so you get the picture: commit new updates to a git rep...

How to render XML error messages separately in Ruby on Rails?

I'm creating a simple XML API in Rails, and currently, when there's an error, it renders the standard HTML error pages in public/, e.g. error in /tests.xml causes rendering of public/404.html. Is there a way to make it render public/404.xml instead? ...

Ruby passing different attribute arguments to same function

Hello, I have a job model which has many attributes. I would like to use graphics to display the sum of some of these attributes. For that, I am using the following code in the javascript portion of the view which produces the graph: <% for job in @daily_jobs %> ['<%= job.day %>',<%= job.walltime %>], <% end %> This returns ...

undefined method `find_link' for #<Cucumber::Rails::World:0x818e02e8> (NoMethodError)

Rspec obviously hates me. I kinda hate him back. #features/step_definitions/custom_steps.rb Then /^I should see the link "([^\"]*)"$/ do |linked_text| find_link(linked_text) end #link.feature Then I should see the link "foo" From terminal: undefined method `find_link' for #<Cucumber::Rails::World:0x818e02e8> (NoMethodError) ./featu...

Rails application permission on apache

What should be the permission on rails app directory on apache server??? ...

xmlhttprequest POST method in rails

In the web, I'm building local file drag and drop upload to the server with the ruby on rails, dragging and drop a file working fine, but how to get the dragged file content in the controller with the drop event? I'm getting the file with event.datatransfer, send file through Javascript with XMLHttpRequest. function handleDrop(event)...

is with_scope threadsafe?

Poking around in the rails code, I ran across with_scope. From what I can tell, it takes the scope type and conditions, merges them into existing conditions for that scope type, yields to the block, then gets rid of the additional scope. So my first thought is in a multithreaded environment (like jruby on rails), what happens if while...

Google Apps Authentication for a Rails App

Hi, I'm currently using Authlogic to handle all user accounts, but our company has switched over to Google apps and I would much rather use that same authentication for all users. My question is - how? I know I'll need the ruby-openid gem but I have yet to integrate authentication with a 3rd party. Any recent examples or tutorials out...