ruby-on-rails

In Rails, is there a way to call request.request_uri in a class (not a controller)?

I'm building a pageview counter for my app using the Garb Ruby wrapper for the Google Analytics API. Doing so means creating a new Module in the 'lib' folder, in which I create a class like this: #lib/Analyze.rb ... class Report extend Garb::Resource metrics :pageviews dimensions :page_path filters :page_path.eql => '/' #the pa...

searching for rails3 plugins

Hi, is there any working in rails3 alternative for following plugins http://github.com/fnando/has_friends http://github.com/fauna/has_many_polymorphs http://github.com/peteonrails/vote_fu Thanks a lot ...

rails toggle problem - ActionView::TemplateError (undefined method `[]' for #<Enumerable::Enumerator

After this rails app has been running fine for over two years... just started getting this one error on only one page. ActionView::TemplateError (undefined method `[]' for #<Enumerable::Enumerator:0xb25fbc4>) on line #10 of app/views/notes/_form.rhtml: 7: <%= @n.text_field 'note', :size => 55 %> 8: </label> 9: <%= link_to_function('Cu...

notify_url of Paypal IPN transaction is not called in Rails Application.

Hi, I am using Active merchnat plugin in my Rails Application .When I am specifying the notify_url,after successful transaction it is not called. Here is my notify url action's Code. Controller:- if (notify = Paypal::Notification.new(request.raw_post)).acknowledge if credit = Credit.find_by_id(notify.invoice) if notify...

Rails associations - problems with altering values, and too much caching!

Suppose I've got a card-game app, which features a Player model, which has an actions integer column; and a Card model. A player can play a card they own, which costs an action; one particular card grants two actions when it's played. If I code this as follows: class Player < ActiveRecord::Base has_many :cards def play_card(card) ...

An easy way to get list of view layouts

I need an easy way to grab layouts that are found in /app/views/layouts. I technically can go in there from Rails.root and grab all files I can, but I'm sure there's a better way. Rails knows where to look for layouts and what extensions are ok. I tried to dig through actionpack but nothing popped out at me. Thanks ...

Rails/MYSQL - Find all with no association

I have an Employee model and a Shift model. Employees have many shifts and shifts have a date. I want to be able to select all employees that are available for a given date i.e. select all employees where no associated shifts exists for a given date. I can select all employees without a shift like this: SELECT users.* FROM users LEFT ...

Git ignore all files in directory expect for specified

My rails app uploads all users photos to a folder /uploads/photos/. I want to ignore everything in this folder in git except for one subfolder /uploads/photos/default/. Is this possible using the .gitignore file? ...

remove whitespace from each array item rails

I found this code: .each_key {|a| self[a].strip! if self[a].respond_to? :strip! } on this website: http://granth.ca/2006/02/strip-whitespace but I assume that is for a hash, I am trying to do the same with an array. I have tried a few different things, but cannot figure it out. Thank you for any help ...

How do I return a text server-response to Uploadify on completed upload?

This is a bit of an premature post, because I'm still grokking the code. But I've looked for a day, and I suspect it's something simple I'm missing about the Actionscript environment. Goal: I have Uploadify uploading to the Rails server. When the file gets uploaded to the server, it gets renamed. I want to respond with the new filepa...

Which Linux commands should I become familiar with as I begin to learn Ruby on Rails?

Hello. I'm just starting to learn Ruby on Rails and I'm developing on a Mac. I'm new to both Mac and Linux and I find myself already struggling to use the commands I need to get things done. For example, I started the rails sever using the :> rails server -d command and I couldn't figure out how to stop it. Ctrl-c, as mentioned in the...

Coping with number signs (hashmarks) in URLs with Ruby's URI library

I'm trying to parse a URI with Ruby's URI library. This URI contains a #. For example, I have the URI: http://twitter.com/#!/dhh/status/26464821879 When I call URI.parse("http://twitter.com/#!/dhh/status/26464821879").path "/" is returned, when I would expect to see "/#!/dhh/status/26464821879" returned. How can I get URI.parse to pro...

Custom URL's in a Rails App

Hello Everybody, This question is going to be very general because I do not know where to start. I want users of my service to be able to add their own custom url's. For example, www.[thierurl].com should be able to access their application's index and show pages. I've seen apps like Tumblr offer this functionality for their front fa...

How best to associate an Address to multiple models in rails?

This question on SO appears to be related to my question, but I'm not sure my question is answered by that. An address can belong to more than one model (UserProfile and Event) What's the correct way to implement this? The basic tables: user_profiles(id) events(id) Options for implementing the addresses table: addresses(id,user_pro...

Why is HABTM generating queries that include an 'id' column?

I have a Role model and Permission model. The Role model: has_and_belongs_to_many :permissions The Permission model: has_and_belongs_to_many :roles The migration to create the permissions_roles table: class CreatePermissionsRoles < ActiveRecord::Migration def self.up create_table :permissions_roles, :id => false do |t| ...

Is it possible to render a partial and force the browser not to load from cache?

I have a window and when it opens, I need to make sure that the image is its latest state. So I thought why not.. render :partial => 'logo', :cache => false but that's not really rails. Any ideas? ...

I'm getting an 'undefined method' error while using delayed_job

I'm using delayed_job and for a method I keep getting this error: undefined method 'shorten!' for #<Status:0x6ce8c6c> Delayed_job works for my other methods such as sending users a confirmation email when they sign up. This is the only method thats giving me the error. The method works when called on directly but it spouts out that erro...

Arel causing infinite loop on aggregation

I have trouble with using Arel to aggregate 2 columns in the same query. When I run this, the whole server freezes for a minute, before the rails dev-server crashes. I suspect an infinite loop :). Maybe I have misunderstood the whole concept of Arel, and I would be grateful if anybody could have a look at it. The expected result of th...

Parsing a complex URL in Ruby

Hello, I'd like to retrieve the value of 'q' in this URL: http://www.google.com/url?sa=X&amp;q=http://nashville.broadwayworld.com/article/Just_in_time_for_Halloween_Circle_Players_does_JEKYLL_HYDE_20101013&amp;ct=ga&amp;cad=:s7:f1:v1:d2:i0:lt:e0:p0:t1286988171:&amp;cd=yQoOdKUFTLo&amp;usg=AFQjCNEg2inHF8hXGEvG-TxMQyMx7YGHkA if I use thi...

Ruby convert single quotes to double quotes in XML

Despite the fact that XML attributs can be defined using single or double quotes, my user is trying to integrate my software with another one that will not accept single quoted attribut values. I user REXML to generate my XMLs. Is there a way to REXML generate double quoted attribute values? If not, is there a way for me to convert it ...