ruby-on-rails

Problem with rails when trying to do rails-v

My friend just shared me this new application and I pulled it from heroku I was just trying to do rails -v and I got denniss$ rails -v /Users/denniss/.rvm/gems/ruby-1.9.2-rc2/gems/bundler-1.0.0.rc.5/lib/bundler/resolver.rb:132:in `block in resolve': Could not find gem 'selenium-webdriver', required by 'capybara', in any of the sources ...

configuring username format in authlogic

How can I configure username to only have alphabets (a-z, A-Z), numericals (0-9) and underscores (_) and no other characters... ...

from_remote_tag sent request http post instead of ajax XMLHTTP request

Hi, I define a submit button with form_remote_tag, <div class="form_row"> <% form_remote_tag :url => {:controller => '/group', :action => 'addgroup'}, :update => 'activitypage' do %> <%= submit_tag "Add!", :class => "submit" %> <% end %> I used fiddler and confirm the rails code was translated into ajax request, u003Cform actio...

Worldwide location (country, region, city) select plugin for Rails, jQuery or Google Maps API?

Is there any plugin which will help to create a dropdown menus for countries, regions and cities? At first user chooses country, then he has his region dropdown menu updated according to which country he has chosen, he chooses region and after that from 3rd menu a city. Plugin can be either for Ruby on Rails, jQuery or maybe javascript ...

Rails 3 is killing me <help>

I just recently switched to Rails 3. I have been through several installation problems and still is unable to do the stuff that I could do in Rails 2. Right now for some reason when I want to do rake db:migrate I get the following error rake aborted! uninitialized constant ActiveSupport::CoreExtensions /Users/denniss/Sites/mp/Rakefil...

deploying rails app to heroku migrations rake error on windows

Hi, I am attempting to deploy my app to heroku via a windows 7 machine. I've made it as far as git push heroku master without running into any major issues but when I try to rake the migrations i get the following error $ heroku rake db:migrate --trace rake aborted! No such file or directory - /disk1/tmp/13403_23723015091620/.bundle...

problem with project MVC structure

in my project i have about 20 html forms with many different <input>'s. This <input>'s are unique in every form and they don't repeated between them. For each form there is a script which get data from form, generate specific file, and push it to the browser. and that's it. no databases, admin, logins/passwords and other usual web-app st...

Add Expires Header in Rails

Now I am trying to implement High web site performance following YSlow rules. In terms of Expires Header, I have configured in nginx like the following: if ($request_uri ~* ".(ico|css|js|gif|jpe?g|png)\?[0-9]+$") { expires max; break; } Yes, I got the good result because I could not see css and javascript files followed by time...

What happens to a user request when a Mongrel thread locks up & gets restarted by monit?

Hi, I cannot find an answer to this anywhere I've looked so hoping someone can help. We run a pack of 30 mongrel servers & have just started to use monit to identify locked threads and restart them. My question is, what happens to the users request, which was being handled by the locked thread when this happens - especially, what do ...

Race conditions in Ruby class methods

I'm working on an API integration project in Ruby and I was about to create a class method to somewhat follow what Rails does with the finder methods but I stopped short of doing so because I'm concerned I might introduce a race condition. I wouldn't be storing anything within the member variables, just instantiating objects with the th...

Rails child object query leads to N+1 problem

Hi, while writing some application for personal use. I find out the child query is not as great as it look. For instance, I have 2 object Category has_many Files File belongs_to Category File.category will access its parent category. But this lead to the famous N+1 problem. For example, I want my homepage to list out 20 newest file...

rails high memory usage

I am planning on using delayed job to run some background analytics. In my initial test I saw tremendous amount of memory usage, so I basically created a very simple task that runs every 2 minutes just to observe how much memory is is being used. The task is very simple and the analytics_eligbile? method always return false, given where...

How do I model this relationship in Rails

I'm a bit new to rails so if this is very basic please bear with me. I am creating something like a chat application. My model looks like this (from schema.rb) create_table "people", :force => true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" t.integer "session_id" end create_table "session...

Ruby on Rails: Avoiding infinite loop when calling .save during an update

I have an order model that has_many :items. Each item has item.price for the cost of said item. I want to add up all of the item prices in the order for a order.total_price. Right now I'm doing that with after_save :update_total_price, :if => "self.saved.nil? " def update_total_price self.total_price = Item.find(item_ids).inject...

how to use multiple broker? (Stomp, ActiveMQ and activemessaging)

I am using ActiveMQ with stomp and activemessaging. I tried to follow the configuration steps in http://code.google.com/p/activemessaging/wiki/Configuration In my broker.yml, I have the following config development: adapter: stomp login: "" passcode: "" host: localhost port: 61613 reliable: true reconnec...

Porting PHP function to Ruby

So as you all probably know already, there is no facebook API for Rails 3 (not well-supported/documented anyway). I am wondering whether porting these PHP API to ruby is a good idea or not. What I mean by porting is writing my own php function that uses FB API and use the output as the ruby input. Is this a good idea? Impossible? ...

Retrieving XRDS document in OpenID using Ruby

I am just playing around with the OpenID protocol. I am trying to send Discovery request and retrieve the XRDS document from google . When I try to do it from the terminal using the curl, I am getting the following output curl --url "https://www.google.com/accounts/o8/id" <?xml version="1.0" encoding="UTF-8"?> <xrds:XRDS xmlns:x...

Deploying a rails app on Weblogic

Have been using the Apache successfully but there's a sudden need of migrating the app and deploying it on Weblogic. Any issues I should be aware of? And is Weblogic Rails 'friendly'? Thanks! ...

validates_exclusion_of in Authlogic custom validations

Hi, I'm trying to use custom validations with Authlogic gem for Rails. In the method "acts_as_authentic" I'm just using some kind of validations such as "merge_validates_format_of", but now I'm trying to use "validates_exclusion_of" that's not working because there are only some of ActiveRecord validation methods implemented for Authlogi...

Rails routing help

I want the url of a user post to be like this: example.com/users/username/post-name How should I set this up? Currently, the post model contains: def to_param name.parameterize end (to hyphenate the post name accordingly) routes.rb contains: map.resources :users map.resources :posts Preferably, I would like to say ...