ruby-on-rails

Ruby Gem Ultraviolet, Rails, Leopard

I cannot get this crazy dependency to work and please don't tell me to go to Snow Leopard because I have a PPC. I have oniguruma, textpow, ultraviolet all installed. I'm using rvm which is probably the problem. Not that rvm is bad it's just that I don't know how to get the paths correct. When I startup a rails app the error I'm getting...

Need help with a code smell

In my Rails application I'm trying to make the controllers skinnier and am having difficulty with one object that I keep having to pass around. The object represents a user's facebook session and is instantiated off of the session so it exists in the controller side of things. Many model methods use it, so it is repeatedly passed in as...

form_for is giving me the wrong url for path_prefixes

Hi I am having a problem with the form_for method in Rails. It is behaving strangely. I have a route with a path prefix, something like: map.resources :beers, :path_prefix => '/:brewery' And I have a form like this (@beer.brewery is a string, just the name of the brewery): <% form_for @beer, :url => { :brewery => @beer.brewery } d...

How to order by multi relation table 's field?

Hi , I need to generate a list of receipts in rails which need to be ordered by item's order relationship field (payment_method_meta_type.name). Models : Receipt Deposit PaymentMethodMetaType In Deposit Model: class Deposit < ActiveRecord::Base belongs_to :payment_method_meta_type has_many :receipts, :class_name=>"Receipt", ...

How to test devise models, controllers and views using RSpec?

Hi, I am used to generating my rspec controllers & models using rspec_X syntax, e.g. script/generate rspec_model Person script/generate rspec_controller Person However if I want to use devise to create a Person model the syntax is: script/generate devise Person which works OK, but does not create any of the rspec test files / dirs...

link to a controller function from the view

I have a function to take ownership of a job which updates the database to update the username in a table row. I want to link to this function from the view and then redirect to the appropriate page. How do you link to a controller function or a model function from the view? from the index i want to have another link beside show, edit...

How would you handle a mixed HAML/ERB team?

I'm a big Haml/Sass fan. Right now I work with a designer who prefers Erb and doesn't speak Haml. I find that working with Erb is slowing me down considerably, and it doesn't seem fair that he should have to pay for that time (he's the client & I'm paid hourly). The erb->haml converter works quite well these days, but I don't know if t...

accessing remote xml in rails

I need to access xml that is located in another web server. Does rails/ruby have a function that allows me to access this xml and then may be store it in a variable so that i can process it with libxml-ruby? ...

expires max caches ajax

Using rails nginx with passenger. I put the following in the nginx.conf file for caching images, js. etc. But now I notice that my ajax calls are cached or rather the expiration is set to some 30 years in future. I would like to have the javascripts cached but not the ajax calls. How do I do it? location ~* ^.+.(jpg|jpeg|gif|png|css|js|...

How do I use a standard active record for some models when i am using the datafabric gem?

I am using the data-fabric gem, sharding between 2 machines. However, I would like to use the standard activerecord functions for some tables. Anyone has a similar experience achieving this? ...

fields_for sending array instead of Hash (Rails 3)

I'm using fields_for in my form like so <%= form_for @user %> ... <%= f.fields_for :photos do |f2| %> <%= f2.radio_button :public, 'true' %> <% end %> ... <% end %> Here are the radio buttons it generates: <input id="user_photos_attributes_0_public_true" name="user[photos_attributes][0][public]" type="radio" value="true" ...

Rails 2.3.8 How is 'id' passed to method in pagination example?

I'm working through "Learning Rails by Example" tutorial by Michael Hartl(11.33).The relevant code is: class PagesController < ApplicationController def home @title = "Home" if signed_in? @micropost = Micropost.new @feed_items = current_user.feed.paginate(:page => params[:page]) end end class User < ActiveRecord::Base def...

Rails validation error messages, customizing the attribute name

If a model has an attribute named "unit" for example, but in your views you refer to this attribute as "unit price", but when you do validation, error messages default to "unit", how do I modify this to say "unit price"? ...

Facebook application unable to pull email address

Folks, I have made several attempts but I am unable to figure out why I keep getting nil for email address. Here is what I am doing - 1) I created an application that asks for all the right extended permissions i.e. email, manage_pages etc that we need for our app. 2) User approves it and I make a Post Authorization call to my applicat...

$.getJSON interpreted differently by IE - Ruby on Rails

Hello, I am trying to do the classic category -> subcategory chained dropdowns (where selecting something in category, populates the subcategory). The code I have works in all browsers except IE (naturally). Here is the JS code I am using: $("body select#category").data_binding({ child: "select#company_subcategory_id", url: "s...

Is there a Ruby on Rails generate migration statement to change "description" from string to text?

It looks like string is limited to 256 characters and text is usually 65536 characters. I tried ruby script/generate migration change_description_to_text description:text but the up and down in the migration file generated are both empty? Is there a way to generate this migration automatically? If added manually using a remove_colu...

How to get Hoptoad Error Notification in Development Environment on Rails

Hi friends Please any one help to solve, how to get hoptoad Error Notification in Development Environment on Rails, I have configured the hoptoad correctly, and even I am getting test mail from hoptoad i.e. by running rake hoptoad:test but other then that i dont get anything, i.e. errors, expections, etc. Please help me to solve thi...

downloading only the header of a file

I'm using mechanize for scraping a website which works nicely, however since you can't tell from a link what kind of file it is linking to e.g. http://somesite.com/images.php?get=123 is it possible to download only the header only? It doesn't have to use mechanize but is there any Rails way of doing this? ...

Is it possible to use "eval" to define just one function (as opposed to one for each)?

Hi folks, today, i am defining a set of variables in a hash that I use in various functions all over the model and the controller. From the code below, you see that I am defining functions like get_stats, get_fans to target the exact variable. My question is, would it be possible to define just one function? NOW: REQ={:USER_STATS_I...

Rails Paperclip plugin stopped working?

Hi Everyone, I am using the Paperclip plugin to manage file uploads to my application. For some reason in the last day or so the plugin/model has stopped working and now returns the following error message: Paperclip::PaperclipError in DeliversController#create Asset model missing required attr_accessor for 'data_file_name' As far ...